Peewee's .count() on a complex multi-join query can return None when the
result wrapper yields an empty cursor for a 0-row result set. Guard with
`or 0` so the response contract (count is always an integer) is upheld.
Note: tier values outside 0–4 already return 422 via FastAPI's ge/le
constraints on the tier parameter, so the reproduced scenario
(tier=99 → count: null) is also covered by validation.
Closes#182
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Dev environment uses sba_postgres container, paperdynasty_dev database,
sba_admin user — not pd_postgres/pd_master as previously documented.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>