Skip to content

Commit

Permalink
Merge pull request #35155 from dimagi/gh/dedupe/no-matching-case-metric
Browse files Browse the repository at this point in the history
Add metric for no matching case in dedupe
  • Loading branch information
gherceg authored Oct 2, 2024
2 parents 2a6e9c7 + 86b7d99 commit 20abb0f
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions corehq/apps/data_interfaces/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -1163,8 +1163,6 @@ def _handle_case_duplicate(self, case, rule):
if is_copied_case(case):
return CaseRuleActionResult()

dedupe_load_counter('unknown', case.domain)()

if not case_matching_rule_criteria_exists_in_es(case, rule):
ALLOWED_ES_DELAY = timedelta(hours=1)
if datetime.utcnow() - case.server_modified_on > ALLOWED_ES_DELAY:
Expand All @@ -1178,6 +1176,7 @@ def _handle_case_duplicate(self, case, rule):
# but disabling this to avoid further quota issues.
# raise ValueError(f'Unable to find current ElasticSearch data for: {case.case_id}')
# Ignore this result for now
dedupe_load_counter('unknown', case.domain, {'result': 'errored'})()
return CaseRuleActionResult(num_errors=1)
else:
# Normal processing can involve latency between when a case is written to the database and when
Expand All @@ -1189,9 +1188,12 @@ def _handle_case_duplicate(self, case, rule):
# inserts into ElasticSearch are asychronous, we can receive cases here that will not yet be
# present in ElasticSearch but will never be processed later. In the short-term, we're avoiding
# this by resaving the case, with the intention to use a more stable approach in the future
dedupe_load_counter('unknown', case.domain, {'result': 'retried'})()
resave_case(rule.domain, case, send_post_save_signal=False)
return CaseRuleActionResult(num_updates=0)

dedupe_load_counter('unknown', case.domain, {'result': 'processed'})()

try:
existing_duplicate = CaseDuplicateNew.objects.get(case_id=case.case_id, action=self)
except CaseDuplicateNew.DoesNotExist:
Expand Down

0 comments on commit 20abb0f

Please sign in to comment.