Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2023-10-06 main -> prod #2439

Merged
merged 1 commit into from
Oct 6, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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()
Loading