From 32a925723644bd9d2b8e8844eba37787fd55f0f3 Mon Sep 17 00:00:00 2001 From: Tadhg O'Higgins <2626258+tadhg-ohiggins@users.noreply.github.com> Date: Fri, 6 Oct 2023 15:32:55 -0700 Subject: [PATCH] Tadhg/add v0 to deprecated table list (#2437) * Add v0 to deprecated table list. Add missing SQL files. * We have to cover SUBMITTED as well as DISSEMINATED. --- ...nd_regenerate_dissemination_from_intake.py | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/backend/dissemination/management/commands/delete_and_regenerate_dissemination_from_intake.py b/backend/dissemination/management/commands/delete_and_regenerate_dissemination_from_intake.py index 32dabc94ad..70e2903164 100644 --- a/backend/dissemination/management/commands/delete_and_regenerate_dissemination_from_intake.py +++ b/backend/dissemination/management/commands/delete_and_regenerate_dissemination_from_intake.py @@ -17,7 +17,16 @@ logger = logging.getLogger(__name__) +def delete_everything_in_dissemination_model(model): + model.objects.all().delete() + + class Command(BaseCommand): + """ + Deletes everything in `dissemination` tables and + regenerates them from data in the intake tables. + """ + help = """ Deletes everything in `dissemination` tables and regenerates them from data in the intake tables. @@ -36,20 +45,22 @@ class Command(BaseCommand): SecondaryAuditor, ] - def delete_everything_in_dissemination_model(self, model): - model.objects.all().delete() - - def handle(self, *args, **kwargs): + def handle(self, *args, **_kwargs): logger.info("Re-running dissemination for all records.") # Begin by deleting all of the dissemination table contents. for model in Command.dissemination_models: - logger.info(f"Deleting {model.__name__}") - self.delete_everything_in_dissemination_model(model) + logger.info("Deleting %s", model.__name__) + delete_everything_in_dissemination_model(model) # Now, re-run dissemination for everything # in the intake tables. + regen_statuses = ( + SingleAuditChecklist.STATUS.DISSEMINATED, + SingleAuditChecklist.STATUS.SUBMITTED, + ) + for sac in SingleAuditChecklist.objects.all(): - if sac.submission_status == SingleAuditChecklist.STATUS.DISSEMINATED: - logger.info(f"Disseminating {sac.report_id}") + if sac.submission_status in regen_statuses: + logger.info("Disseminating %s, ", sac.report_id) sac.disseminate()