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

219214 rdi dedup statistics against population #4436

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
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
25 changes: 12 additions & 13 deletions src/hct_mis_api/apps/registration_data/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion src/hct_mis_api/apps/registration_datahub/celery_tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Loading