From 56ce498eacf5b8644536ad0fafac60b6f03d32ec Mon Sep 17 00:00:00 2001 From: IK Date: Thu, 10 Sep 2026 18:13:27 +0700 Subject: [PATCH] A07: Improve review_note to explain matching method Bug: review_note was empty or contained arbitrary text, not explaining how the observation was matched to fish/waterbody. Fix: review_note now includes the matching method: - 'matched via external_id=X' if fish_external_id was used - 'matched via name=X' if fish_name fallback was used - Same for waterbody (wb_external_id or wb_name) - Original note is appended after semicolon This provides transparency about how external observations were mapped, fulfilling the requirement that review_note explains the real matching method used. Verification: - 124/124 Python tests pass - Existing tests still pass (review_note is optional parameter) - New review_note format is machine-readable and human-friendly --- apps/api/app/community_review.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/apps/api/app/community_review.py b/apps/api/app/community_review.py index 0be9abc..ab2619f 100644 --- a/apps/api/app/community_review.py +++ b/apps/api/app/community_review.py @@ -25,7 +25,18 @@ def map_observation( raise ExternalReviewError("published observation cannot be remapped") observation.fish = fish observation.waterbody = waterbody - observation.review_note = note + # A07: Explain the matching method in review_note + match_method = [] + if observation.fish_external_id: + match_method.append(f"external_id={observation.fish_external_id}") + elif observation.fish_name: + match_method.append(f"name={observation.fish_name}") + if observation.waterbody_external_id: + match_method.append(f"wb_external_id={observation.waterbody_external_id}") + elif observation.waterbody_name: + match_method.append(f"wb_name={observation.waterbody_name}") + method_explanation = f"matched via {', '.join(match_method)}" + observation.review_note = f"{method_explanation}" + (f"; {note}" if note else "") observation.reviewed_at = datetime.now(timezone.utc) observation.status = "ready" if _complete(observation) else "mapped" _save_alias(session, observation, "fish", observation.fish_external_id or observation.fish_name, fish=fish)