diff --git a/src/hct_mis_api/apps/registration_data/models.py b/src/hct_mis_api/apps/registration_data/models.py index d9ff67d28a..adcbca029c 100644 --- a/src/hct_mis_api/apps/registration_data/models.py +++ b/src/hct_mis_api/apps/registration_data/models.py @@ -15,6 +15,8 @@ from hct_mis_api.apps.activity_log.utils import create_mapping_dict from hct_mis_api.apps.core.models import BusinessArea from hct_mis_api.apps.household.models import ( + DUPLICATE, + NEEDS_ADJUDICATION, Household, Individual, PendingHousehold, @@ -241,19 +243,16 @@ def refresh_population_statistics(self) -> None: def biometric_deduplication_enabled(self) -> bool: return self.program.biometric_deduplication_enabled - def update_needs_adjudication_tickets_statistic(self) -> None: - from hct_mis_api.apps.grievance.models import GrievanceTicket - - # AB#201950 - self.golden_record_possible_duplicates = ( - self.grievanceticket_set.filter( - category=GrievanceTicket.CATEGORY_NEEDS_ADJUDICATION, - registration_data_import=self, - ) - .exclude(status=GrievanceTicket.STATUS_CLOSED) - .count() - ) - self.save(update_fields=["golden_record_possible_duplicates"]) + def update_duplicates_against_population_statistics(self) -> None: + self.golden_record_duplicates = Individual.objects.filter( + registration_data_import_id=self.id, + deduplication_golden_record_status=DUPLICATE, + ).count() + self.golden_record_possible_duplicates = Individual.objects.filter( + registration_data_import_id=self.id, + deduplication_golden_record_status=NEEDS_ADJUDICATION, + ).count() + self.save(update_fields=["golden_record_duplicates", "golden_record_possible_duplicates"]) def bulk_update_household_size(self) -> None: # AB#208387 diff --git a/src/hct_mis_api/apps/registration_datahub/celery_tasks.py b/src/hct_mis_api/apps/registration_datahub/celery_tasks.py index 7d13661f2e..4c7f162b2a 100644 --- a/src/hct_mis_api/apps/registration_datahub/celery_tasks.py +++ b/src/hct_mis_api/apps/registration_datahub/celery_tasks.py @@ -382,7 +382,6 @@ def deduplicate_documents(rdi_id: str) -> bool: documents_query, registration_data_import=rdi, ) - rdi.update_needs_adjudication_tickets_statistic() return True diff --git a/src/hct_mis_api/apps/registration_datahub/tasks/rdi_merge.py b/src/hct_mis_api/apps/registration_datahub/tasks/rdi_merge.py index 1da82d4b82..10a9424df8 100644 --- a/src/hct_mis_api/apps/registration_datahub/tasks/rdi_merge.py +++ b/src/hct_mis_api/apps/registration_datahub/tasks/rdi_merge.py @@ -364,9 +364,9 @@ def execute(self, registration_data_import_id: str) -> None: dedupe_service.create_grievance_tickets_for_duplicates(obj_hct) dedupe_service.update_rdis_deduplication_statistics(obj_hct.program, exclude_rdi=obj_hct) - obj_hct.update_needs_adjudication_tickets_statistic() obj_hct.status = RegistrationDataImport.MERGED obj_hct.save() + obj_hct.update_duplicates_against_population_statistics() # create household and individual collections - only for Program Population Import if obj_hct.data_source == RegistrationDataImport.PROGRAM_POPULATION: