From e2223c6f24392dcff26ed0662e961073a51d8f1c Mon Sep 17 00:00:00 2001 From: IK Date: Thu, 10 Sep 2026 19:42:56 +0700 Subject: [PATCH] A07: Fix _auto_publish to allow fish name fallback without external_id Bug: 'observation.fish_external_id is None' in early return prevented auto-publishing observations that only have fish_name (no external_id), even when name-based fallback matching was available. Fix: - Removed fish_external_id check from early return condition - Auto-publish now tries external_id first, falls back to name match - review_note now describes actual matching method: 'Auto-matched: fish via external_id/name, waterbody via external_id/name' - Previous note 'Automatically matched by previously reviewed source aliases' was misleading when name fallback was used Verification: - 14/14 community_importer tests pass - 124/124 Python tests pass (1 skipped) - Observations without fish_external_id can now auto-publish via name match - review_note accurately describes matching method --- apps/api/app/community_importer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/api/app/community_importer.py b/apps/api/app/community_importer.py index b908331..6873dc8 100644 --- a/apps/api/app/community_importer.py +++ b/apps/api/app/community_importer.py @@ -106,7 +106,6 @@ def _auto_publish(session: Session, observation: ExternalObservation) -> bool: or observation.status not in {"staged", "mapped", "ready"} or not observation.source.enabled - or observation.fish_external_id is None or observation.x is None or observation.y is None or observation.weight_g is None @@ -149,7 +148,10 @@ def _auto_publish(session: Session, observation: ExternalObservation) -> bool: observation.fish = fish observation.waterbody = waterbody observation.status = "ready" - observation.review_note = "Automatically matched by previously reviewed source aliases" + # A07: Describe actual matching method used + fish_method = "external_id" if observation.fish_external_id else "name" + wb_method = "external_id" if observation.waterbody_external_id else "name" + observation.review_note = f"Auto-matched: fish via {fish_method}, waterbody via {wb_method}" publish_observation(session, observation) return True