Enrich's summary stops reporting a negative count

"136 entries (136 added/refreshed this run; -11 already present or
waiting)" — local library entries were counted in the same tally as API
fetches, but they have no API target, so the remainder went negative
once eleven off-BGG games existed. The two populations are now counted
and named separately, and zero-valued clauses are omitted:
"136 entries (0 fetched from BGG; 11 local-only; 125 already present or
waiting)."

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016jXZFSTZQKzAC8fqpWSz9g
This commit is contained in:
Eric Wagoner
2026-08-05 23:32:55 -04:00
co-authored by Claude Fable 5
parent b5e13be335
commit 2e1693c0be
3 changed files with 7235 additions and 3 deletions
+40
View File
@@ -278,3 +278,43 @@ def test_local_rows_enrich_from_their_own_reads(tmp_path):
# idempotent: a second run keeps the entry (no prune, no dupe)
games2 = run_enrich(cfg, client=client)
assert key in games2
def test_summary_counts_local_and_api_entries_separately(tmp_path, capsys):
"""Local entries have no API target, so folding them into the fetched
tally made "already present or waiting" report a NEGATIVE count."""
from bggpipe.enrich import run_enrich
cfg = Config(data_dir=tmp_path / "data")
cfg.data_dir.mkdir(parents=True)
write_matches(
cfg.matches_path,
[
{
"title_raw": "Homebrew",
"bgg_id": "",
"bgg_name": "",
"year": "",
"type": "",
"match_status": "local",
"version_id": "",
"version_name": "",
"version_status": "",
"candidates_json": "[]",
"version_candidates_json": "[]",
"source_photos": "shelf.jpg",
}
],
)
cfg.titles_path.write_text("[]")
client = BGGClient(
cache_dir=cfg.data_dir / "cache",
transport=httpx.MockTransport(_no_network),
)
games = run_enrich(cfg, client=client)
out = capsys.readouterr().out
assert len(games) == 1
assert "1 local-only" in out
import re as _re
assert not _re.search(r"-\d", out) # no negative tallies