Skip to content

Commit

Permalink
Merge pull request #904 from egovernments/rollOutDashboardBackup
Browse files Browse the repository at this point in the history
Roll out dashboard backup
  • Loading branch information
pradeepkumarcm-egov authored Aug 12, 2024
2 parents 4237740 + db54ef7 commit edc0c1b
Showing 1 changed file with 29 additions and 4 deletions.
33 changes: 29 additions & 4 deletions utilities/rollout-dashboard-cronjob/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,19 @@ def createEntryForRollout(tenant,activeUsersCount,totalAdvance, totalPenalty,tot
if connection:
cursor.close()
connection.close()
def is_saturdaydayOrSunday():
print("DateTime today :",datetime.today().weekday())
return datetime.today().weekday() in [5, 6]
def get_daterange():
if is_saturdaydayOrSunday():
return [
'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)'
]
else:
return ['Last seven days', 'Last 15 days', 'currentMonth-Till date', 'Consolidated (As on date)', 'FY to date']

def process():
print("continue is the process")
Expand All @@ -817,15 +830,27 @@ def process():
cursor = connection.cursor()

print("cursor: ",cursor)

INSERT_INTO_ROLLOUT_LEGACY_QUERY=""" INSERT INTO roll_out_dashboardlegacy(
id, tenantid, tenantname, projectcode, zone, circle, division, subdivision, section, active_users_count,
total_advance, total_penalty, total_connections, active_connections, last_demand_gen_date,
demand_generated_consumer_count, total_demand_amount, collection_till_date, last_collection_date,
expense_count, count_of_electricity_expense_bills, no_of_paid_expense_bills, last_expense_txn_date,
total_amount_of_expense_bills, total_amount_of_electricity_bills, total_amount_of_paid_expense_bills,
date_range, createdtime) select id, tenantid, tenantname, projectcode, zone, circle, division, subdivision, section, active_users_count,
total_advance, total_penalty, total_connections, active_connections, last_demand_gen_date,
demand_generated_consumer_count, total_demand_amount, collection_till_date, last_collection_date,
expense_count, count_of_electricity_expense_bills, no_of_paid_expense_bills, last_expense_txn_date,
total_amount_of_expense_bills, total_amount_of_electricity_bills, total_amount_of_paid_expense_bills,
date_range, createdtime from roll_out_dashboard """
cursor.execute(INSERT_INTO_ROLLOUT_LEGACY_QUERY)
connection.commit()

DROPPING_TABLE_QUERY = " drop table if exists roll_out_dashboard "
cursor.execute(DROPPING_TABLE_QUERY)

connection.commit()

createTableQuery = createTable()
cursor.execute(createTableQuery)

connection.commit()

print("table dropped")
Expand All @@ -842,7 +867,7 @@ def process():
for tenant in tenants:
print("Tenant:", tenant['tenantId'])
activeUsersCount= getActiveUsersCount(tenant['tenantId'])
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)']
daterange = get_daterange()
for i,date in enumerate(daterange):
startdate,enddate= getdaterange(date)
totalAdvance= getTotalAdvanceCreated(tenant['tenantId'],startdate,enddate)
Expand Down

0 comments on commit edc0c1b

Please sign in to comment.