303284: Add deduplication engine reference PK to Individual model and…#5799
Open
303284: Add deduplication engine reference PK to Individual model and…#5799
Conversation
… related services - Introduced a new field `deduplication_engine_reference_pk` in the Individual model to facilitate communication with the biometric deduplication engine. - Updated the CreateLaxIndividuals endpoint to include this reference in the validated data. - Enhanced the BiometricDeduplicationService to utilize the new reference PK for individual identification during deduplication processes. - Added tests to ensure the correct usage of the deduplication reference PK in various service methods and endpoints.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## develop #5799 +/- ##
========================================
Coverage 91.06% 91.06%
========================================
Files 500 500
Lines 34264 34281 +17
Branches 3540 3542 +2
========================================
+ Hits 31201 31218 +17
Misses 2272 2272
Partials 791 791
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
MarekBiczysko
requested changes
Mar 11, 2026
| migrations.AddField( | ||
| model_name="individual", | ||
| name="deduplication_engine_reference_pk", | ||
| field=models.CharField( |
| false_positive_pair = IgnoredFilenamesPair(first=individual1_photo, second=individual2_photo) | ||
| self.api.report_false_positive_duplicate(false_positive_pair, program.unicef_id) | ||
|
|
||
| def report_individuals_status(self, program: Program, individual_ids: list[str], action: str) -> None: |
Contributor
There was a problem hiding this comment.
this function should now take individuals [Queryset] as an argument to avoid unnecessary queries
Contributor
There was a problem hiding this comment.
and then we can do just
id_to_reference_pk = {
str(individual.pk): self._reference_pk_for_individual(individual) for individual in individuals.only("id", "deduplication_engine_reference_pk")
}
Comment on lines
+363
to
386
| reference_to_individual_id: dict[str, str] = {} | ||
| for pk, dedup_reference_pk in PendingIndividual.objects.filter( | ||
| registration_data_import__in=rdis | ||
| ).values_list( | ||
| "pk", "deduplication_engine_reference_pk" | ||
| ): | ||
| reference_pk = dedup_reference_pk or str(pk) | ||
| individual_ids.append(reference_pk) | ||
| reference_to_individual_id[reference_pk] = str(pk) | ||
|
|
||
| data = self.get_deduplication_set_results(program, individual_ids) | ||
| similarity_pairs = [ | ||
| SimilarityPair( | ||
| score=item["score"], | ||
| status_code=item["status_code"], | ||
| first=item["first"]["reference_pk"] or None, | ||
| second=item["second"]["reference_pk"] or None, | ||
| first=self._resolve_individual_id_from_reference( | ||
| (item.get("first") or {}).get("reference_pk"), | ||
| reference_to_individual_id, | ||
| ), | ||
| second=self._resolve_individual_id_from_reference( | ||
| (item.get("second") or {}).get("reference_pk"), | ||
| reference_to_individual_id, | ||
| ), | ||
| ) |
Contributor
There was a problem hiding this comment.
PendingIndividual.objects.filter(registration_data_import__in=rdis).only(
"id", "deduplication_engine_reference_pk"
)
)
reference_to_individual_id = {
self._reference_pk_for_individual(individual): str(individual.pk)
for individual in pending_individuals
}
data = self.get_deduplication_set_results(program, list(reference_to_individual_id))
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… related services
deduplication_engine_reference_pkin the Individual model to facilitate communication with the biometric deduplication engine.