(20251126) Now a separate Cron Script does the Selenium automation and caches the results in a JSON file.

This commit is contained in:
2025-11-26 13:56:48 +05:30
parent f81693306f
commit d9090be865
7 changed files with 337 additions and 89 deletions
+12 -32
View File
@@ -175,39 +175,19 @@ async def muster_roll_report_generate(
success = False
report_data = None
# Get the muster roll data:
async with current_app.chrome_semaphore:
report_data = muster_roll.load(
cosec_url = inbound_headers.cosecUrl,
username = inbound_headers.cosecUsername,
password = inbound_headers.cosecPassword,
group_ids = inbound_data.groupIds,
on_date = inbound_data.onDate,
)
# Figure out the paths:
proj_dir = files.get_parent_directory(
files.get_file_directory(include_filename = False),
depth = 4
)
cache_file = os.path.join(proj_dir, "local", "cache", "muster_roll_cache.json")
# If data was loaded:
if report_data is not None:
# report_data = report_data.copy()
# report_data = report_data[[
# "User ID", "User Name", "Category Name",
# "Grade Name", "Branch Name", "Department Name",
# "Direct Reporting", "Level-1"
# ]]
# unique_branches = report_data["Branch Name"].unique().tolist()
# unique_depts = report_data[["Branch Name", "Department Name"]].drop_duplicates().to_dict(orient = "records")
# unique_reportees = report_data[["Branch Name", "Department Name", "Direct Reporting"]].drop_duplicates().to_dict(orient = "records")
# unique_combos = {
# "Branch Name": unique_branches,
# "Department Name": unique_depts,
# "Direct Reporting": unique_reportees
# }
# report_data = unique_combos
##############
# Added by Yatmesh on 25 nov 15:08
report_data = report_data.where(report_data.notna(), None)
###################################
report_data = report_data.to_dict(orient = "records")
success = True
# Read the report:
try: report_data = json.from_file(cache_file)
except Exception as e: pass
# Note down the status of success or failure:
success = True if report_data else False
# ┳┓
# ┣┫┏┓┏┏┓┏┓┏┓┏┏┓