Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jasonleibowitz/53dcfea352e13b810a721228c32af3fd to your computer and use it in GitHub Desktop.
Save jasonleibowitz/53dcfea352e13b810a721228c32af3fd to your computer and use it in GitHub Desktop.
Personal namespace deploys do not generate `express_expressperiodicreportrow` objects. This is a script to auto-generate them. However, in personal namespace deploys (eks-test or sandbox) we do not have sufficient resources to run the script like we do in prod. Therefore, this version of the script chunks the objects we need to iterate over.
from more_itertools import more
from fund_admin.express.overview.services import ExpressDashboardService
from fund_admin.express.overview.queries import firms_for_dashboard, funds_for_dashboard
from fund_admin.express.periodic_reporting.models import ReportingPeriod
from fund_admin.express.periodic_reporting.services import ExpressPeriodicReportService
BATCH_SIZE = 15
# Add the missing Express Entity rows
dashboard_service = ExpressDashboardService()
dashboard_service._delete_outdated()
dashboard_service._update_users()
firms = firms_for_dashboard()
for batched_firms in more.chunked(firms, BATCH_SIZE):
funds = funds_for_dashboard().filter(firm_id__in=[firm.id for firm in batched_firms])
dashboard_service._update_express_firm_rows_for_firms(firms)
dashboard_service._update_express_entities_for_funds(funds)
# Rebuild the report and rows
service = ExpressPeriodicReportService()
report, _ = service.get_or_create(report_period=ReportingPeriod.YEARLY, report_year=2022)
service.set_correct_periodic_report_rows(report=report)
service.reload_report(report_id=report.id)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment