Skip to content

Commit

Permalink
re-enable total_num_records_post
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimpe committed Oct 16, 2024
1 parent 5b823bc commit 3e524bb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tdrs-backend/tdpservice/scheduling/parser_task.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
from tdpservice.parsers.aggregates import case_aggregates_by_month, total_errors_by_month
from tdpservice.parsers.util import log_parser_exception, make_generate_parser_error
from tdpservice.email.helpers.data_file import send_data_submitted_email
from tdpservice.search_indexes.models.reparse_meta import ReparseMeta


logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -65,6 +66,7 @@ def parse(data_file_id, reparse_id=None):
file_meta.success = True
file_meta.finished_at = timezone.now()
file_meta.save()
ReparseMeta.set_total_num_records_post(ReparseMeta.objects.get(pk=reparse_id))
else:
recipients = User.objects.filter(
stt=data_file.stt,
Expand Down
8 changes: 8 additions & 0 deletions tdrs-backend/tdpservice/search_indexes/models/reparse_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

from django.db import models
from django.db.models import Max
from tdpservice.search_indexes.util import count_all_records
import logging

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -116,3 +117,10 @@ def get_latest():
if max_pk.get("pk__max", None) is None:
return None
return ReparseMeta.objects.get(pk=max_pk["pk__max"])

@staticmethod
def set_total_num_records_post(meta_model):
"""Update the total_num_records_post field once reparse has completed."""
if meta_model.is_finished:
meta_model.total_num_records_post = count_all_records()
meta_model.save()

0 comments on commit 3e524bb

Please sign in to comment.