Skip to content

Commit

Permalink
Tadhg/add v0 to deprecated table list (#2437)
Browse files Browse the repository at this point in the history
* Add v0 to deprecated table list.

Add missing SQL files.

* We have to cover SUBMITTED as well as DISSEMINATED.
  • Loading branch information
tadhg-ohiggins authored Oct 6, 2023
1 parent 0b40195 commit 32a9257
Showing 1 changed file with 19 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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()

0 comments on commit 32a9257

Please sign in to comment.