From af38e1f44fbe5c2503917e8a9757e21b3c6e572d Mon Sep 17 00:00:00 2001 From: Debasish Chakraborty <117706910+debasishchakraborty-egovt@users.noreply.github.com> Date: Thu, 4 Jan 2024 19:30:43 +0530 Subject: [PATCH] Update app.py --- utilities/rollout-dashboard-cronjob/app.py | 40 +++++++++++++++++----- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/utilities/rollout-dashboard-cronjob/app.py b/utilities/rollout-dashboard-cronjob/app.py index 2ca6fc420..24e20f74e 100644 --- a/utilities/rollout-dashboard-cronjob/app.py +++ b/utilities/rollout-dashboard-cronjob/app.py @@ -696,7 +696,11 @@ def getdaterange(i): lastepoch = enddate.strftime('%s') + '000' if i == 'Quarter-1': - year = datetime.now().year + month = datetime.now().month + if(month < 4): + year = datetime.now().year-1 + else: + year = datetime.now().year start_date = datetime(year, 4, 1) end_date = datetime(year, 6, 30) end = datetime.combine(end_date,time.max) @@ -704,7 +708,11 @@ def getdaterange(i): lastepoch = end.strftime('%s') + '000' if i == 'Quarter-2': - year = datetime.now().year + month = datetime.now().month + if(month < 4): + year = datetime.now().year-1 + else: + year = datetime.now().year start_date = datetime(year, 7, 1) end_date = datetime(year, 9, 30) end = datetime.combine(end_date,time.max) @@ -712,20 +720,36 @@ def getdaterange(i): lastepoch = end.strftime('%s') + '000' if i == 'Quarter-3': - year = datetime.now().year + month = datetime.now().month + if(month < 4): + year = datetime.now().year-1 + else: + year = datetime.now().year start_date = datetime(year, 10, 1) end_date = datetime(year, 12, 31) end = datetime.combine(end_date,time.max) epochnow = start_date.strftime('%s') + '000' lastepoch = end.strftime('%s') + '000' + + if i == 'Quarter-4': + year = datetime.now().year + start_date = datetime(year, 1, 1) + end_date = datetime(year, 3, 31) + end = datetime.combine(end_date,time.max) + epochnow = start_date.strftime('%s') + '000' + lastepoch = end.strftime('%s') + '000' if i == 'FY to date': today = datetime.now().year - start_date = datetime(today, 4, 1) + month = datetime.now().month + if(month < 4): + start_date = datetime(today-1, 4, 1) + else: + start_date = datetime(today, 4, 1) epochnow = start_date.strftime('%s') + '000' lastepoch = datetime.now().strftime('%s') + '000' - if i == 'Previous 1st FY (22-23)': + if i == 'Previous 1st FY (23-24)': today = datetime.now().year lastyear = today-1 start_date = datetime(lastyear, 4, 1) @@ -734,7 +758,7 @@ def getdaterange(i): epochnow = start_date.strftime('%s') + '000' lastepoch = enddate.strftime('%s') + '000' - if i == 'Previous 2nd FY (21-22)': + if i == 'Previous 2nd FY (22-23)': today = datetime.now().year start_date = datetime(today-2, 4, 1) end_date = datetime(today-1, 4, 1) + timedelta(days=-1) @@ -743,7 +767,7 @@ def getdaterange(i): lastepoch = enddate.strftime('%s') + '000' - if i == 'Previous 3rd FY (20-21)': + if i == 'Previous 3rd FY (21-22)': today = datetime.now().year start_date = datetime(today-3, 4, 1) end_date = datetime(today-2, 4, 1) + timedelta(days=-1) @@ -816,7 +840,7 @@ def process(): tenants = getGPWSCHeirarchy() for tenant in tenants: activeUsersCount= getActiveUsersCount(tenant['tenantId']) - daterange = ['Last seven days','Last 15 days','currentMonth-Till date','Previous Month','Quarter-1','Quarter-2','Quarter-3','Consolidated (As on date)','FY to date','Previous 1st FY (22-23)','Previous 2nd FY (21-22)','Previous 3rd FY (20-21)'] + daterange = ['Last seven days','Last 15 days','currentMonth-Till date','Previous Month','Quarter-1','Quarter-2','Quarter-3','Quarter-4','Consolidated (As on date)','FY to date','Previous 1st FY (23-24)','Previous 2nd FY (22-23)','Previous 3rd FY (21-22)'] for i,date in enumerate(daterange): startdate,enddate= getdaterange(date) totalAdvance= getTotalAdvanceCreated(tenant['tenantId'],startdate,enddate)