mirror of
https://github.com/cisagov/manage.get.gov.git
synced 2025-08-04 00:42:16 +02:00
fix populate script
This commit is contained in:
parent
f7b2e38bba
commit
207a3ac3aa
1 changed files with 4 additions and 4 deletions
|
@ -20,16 +20,16 @@ class Command(BaseCommand, PopulateScriptTemplate):
|
|||
|
||||
# Retrieve and order audit log entries by timestamp in descending order
|
||||
audit_log_entries = LogEntry.objects.filter(object_pk=record.pk).order_by("-timestamp")
|
||||
|
||||
# Loop through logs in descending order to find most recent status change
|
||||
for log_entry in audit_log_entries:
|
||||
if 'status' in LogEntry.changes_dict:
|
||||
if 'status' in log_entry.changes_dict:
|
||||
record.last_status_update = log_entry.timestamp.date()
|
||||
break
|
||||
|
||||
# Loop through logs in ascending order to find first submission
|
||||
for log_entry in audit_log_entries.reverse():
|
||||
if log_entry.changes_dict['status'](1) == 'Submitted':
|
||||
status = log_entry.changes_dict.get('status')
|
||||
if status and status[1] == 'Submitted':
|
||||
record.first_submitted_date = log_entry.timestamp.date()
|
||||
break
|
||||
|
||||
|
@ -42,4 +42,4 @@ class Command(BaseCommand, PopulateScriptTemplate):
|
|||
|
||||
def should_skip_record(self, record) -> bool:
|
||||
# make sure the record had some kind of history
|
||||
return LogEntry.objects.filter(object_pk=record.pk).exists()
|
||||
return not LogEntry.objects.filter(object_pk=record.pk).exists()
|
Loading…
Add table
Add a link
Reference in a new issue