Skip to content

fix(cli): tb export mentions agency buyers on an agency-only DB (#143) - #201

Merged
alexwolson merged 1 commit into
mainfrom
fix-143-export-agency-only-count
Jul 28, 2026
Merged

fix(cli): tb export mentions agency buyers on an agency-only DB (#143)#201
alexwolson merged 1 commit into
mainfrom
fix-143-export-agency-only-count

Conversation

@alexwolson

Copy link
Copy Markdown
Collaborator

Closes #143.

The bug

counts['solicitation'] in _cmd_export's success line counts the City spine alone. On a DB
that has agency data (agency_solicitation/agency_award/agency_bid + the export buyers
section) but no City-spine sync data, tb export printed Exported 0 solicitations to <path>
— even though it correctly wrote a full buyers section. A successful export read as though it
did nothing.

The fix

Matches the issue's own suggested wording: mention the agency buyer count alongside
solicitations when it's non-zero.

buyers = counts.get("buyer", 0)
detail = (f"{counts['solicitation']} solicitations + {buyers} agency buyer(s)"
         if buyers else f"{counts['solicitation']} solicitations")
print(f"Exported {detail} to {written}")

buyer is only ever non-zero once agency enrichment has seeded it (seed_buyers), so the plain
City-spine case — the overwhelming majority of real exports — is completely unaffected: no
+0 agency buyer(s) clutter on a run that's never touched agencies.

Verification

Live, both cases:

agency-only DB:  Exported 0 solicitations + 3 agency buyer(s) to .../bids.json
plain fresh DB:  Exported 0 solicitations to .../bids.json

2 new tests, confirmed genuinely red against the pre-fix code by reverting the fix in place:
the agency-only assertion fails with exactly the string this issue reports, while the plain-DB
test stays green throughout — proving the fix is targeted. Restored after.

776 tests passing.

🤖 Generated with Claude Code

https://claude.ai/code/session_01W53WHx8mm2UHuLFAQWeF62

`counts['solicitation']` is the CITY SPINE alone. On a DB that has agency
data (agency enrichment has run) but no City-spine `sync` data, the export
correctly wrote a full `buyers` section, but the success line read
`Exported 0 solicitations to <path>` -- indistinguishable from an export
that genuinely did nothing.

`buyer` is only ever non-zero once agency enrichment has seeded it, so the
plain City-spine case (the overwhelming majority of real exports) is
unaffected -- verified live both ways:

    agency-only DB:  Exported 0 solicitations + 3 agency buyer(s) to ...
    plain fresh DB:  Exported 0 solicitations to ...

2 new tests. Confirmed red against the pre-fix code (the agency-only
assertion fails with the exact string this issue reports; the plain-DB
test stays green throughout), then restored. 776 tests passing.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01W53WHx8mm2UHuLFAQWeF62
@alexwolson
alexwolson merged commit b349a2d into main Jul 28, 2026
1 check passed
@alexwolson
alexwolson deleted the fix-143-export-agency-only-count branch July 28, 2026 17:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Low priority: tb export prints 'Exported 0 solicitations' on an agency-only DB

1 participant