Peach: Local-first video metadata scraper and media manager.
fix(review): 没记下取值的批准记录不算 official 已确认
longmeidao03c6e3abe832
diff --git a/docs/adr/0018-narrow-auto-apply-for-empty-scraped-fields.md b/docs/adr/0018-narrow-auto-apply-for-empty-scraped-fields.mdindex 82756b8bb..a1e7b40f2 100644--- a/docs/adr/0018-narrow-auto-apply-for-empty-scraped-fields.md+++ b/docs/adr/0018-narrow-auto-apply-for-empty-scraped-fields.md@@ -45,6 +45,9 @@ javbus 补空候选全部滞留人工,补的都是账本里空着的发行日(r18dev 10、aventertainment 9、libredmm 1),挑战方无一例外是 javbus——`SOURCE_SPECS`早就排好了序,让人再判一遍等于把定好的信任模型丢回给人。没有落库记录的行照常进队列:现值来路不明时 community 的异议有意义。现值与记录不符(被别的动作改过)时同样交回人工。+**只有记下了取值的记录才算数。** 人工批准写的 note 只有 `candidate_key` 与 `source`,+证明不了账本现在这一个是它写的;拿它当已确认会把 `_metadata_decision_is_stale`+本该重开的字段永久压在队列外面。判据实现见 `metadata_auto_apply_candidate`;执行入口是 `POST /api/review/auto-apply`,走正常写事务,因而同样受只读端闸门约束。diff --git a/src/peach/web_review.py b/src/peach/web_review.pyindex 13f2b291d..6e0e5bb84 100644--- a/src/peach/web_review.py+++ b/src/peach/web_review.py@@ -508,8 +508,12 @@ def _drop_community_challenges_to_official(connection, rows: list[dict]) -> listexcept (TypeError, ValueError):continuespec = SOURCE_SPECS.get(str(parsed.get("source") or "").strip())- if spec is not None and spec.official:- official_values[str(item_key)] = str(parsed.get("value") or "")+ value = str(parsed.get("value") or "").strip()+ # 只认记下了取值的那种记录。人工批准的 note 只记 `candidate_key` 与 `source`,+ # 证明不了账本现在这一个就是它写的;候选后来消失时更是无从判断。拿它当+ # 「official 已确认」会把该重开的字段永久压在队列外面。+ if value and spec is not None and spec.official:+ official_values[str(item_key)] = valueif not official_values:return rows@@ -518,8 +522,7 @@ def _drop_community_challenges_to_official(connection, rows: list[dict]) -> listif item_key not in official_values:return True# 现值被别的动作改过就不能再算「official 写的那一个」,交回人工。- recorded = official_values[item_key].strip()- if recorded and recorded != str(row.get("current_value") or "").strip():+ if official_values[item_key] != str(row.get("current_value") or "").strip():return Truereturn any((spec := SOURCE_SPECS.get(str(c.get("source") or "").strip())) is not Nonediff --git a/tests/test_web_review.py b/tests/test_web_review.pyindex 3403eb22c..0eeba97f4 100644--- a/tests/test_web_review.py+++ b/tests/test_web_review.py@@ -283,6 +283,29 @@ class ReviewQueueTests(unittest.TestCase):])self.assertEqual(self.queue_keys("metadata_fields"), ["FFF"])+ def test_a_decision_without_a_recorded_value_never_suppresses_the_row(self):+ """人工批准的 note 只记 `candidate_key` 与 `source`,不记写进去的值。++ 没记值就证明不了账本现在这一个是它写的,拿它当「official 已确认」会把+ `_metadata_decision_is_stale` 本该重开的字段永久压在队列外面。+ """+ self._asset(98, "GGG-7", "GGG-7.mp4")+ con = sqlite3.connect(self.db_path)+ try:+ con.execute(+ "INSERT INTO review_decision(category,item_key,status,note,updated_at) "+ "VALUES('metadata_fields','GGG','approved',?,'2026-08-30T00:00:00Z')",+ (json.dumps({"candidate_key": "GGG:release_date:r18dev:gone",+ "source": "r18dev", "user_note": ""}),))+ con.commit()+ finally:+ con.close()+ self.write_metadata_rows([+ {"item_key": "GGG", "field": "release_date", "current": "2016-06-06",+ "candidates": ["2016-09-09"], "code": "GGG-7", "source": "javbus"},+ ])+ self.assertEqual(self.queue_keys("metadata_fields"), ["GGG"])+def test_metadata_candidates_that_repeat_the_current_value_never_queue(self):"""复核的成本是注意力:和现值一模一样的行会把真正要判的淹掉。