Skip to content

Add cats to the pet pool with a corrected multi-species search#143

Merged
Smoss merged 5 commits into
masterfrom
smoss/multi-species-vendored-client
Jul 22, 2026
Merged

Add cats to the pet pool with a corrected multi-species search#143
Smoss merged 5 commits into
masterfrom
smoss/multi-species-vendored-client

Conversation

@Smoss

@Smoss Smoss commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Closes #115. Reimplements #124 — which was reverted in #132 after breaking in production — as a single hand-rolled search against the RescueGroups API, based directly on master (no vendored client; the generated-client approach from #138 was dropped in favor of keeping the codebase's manual HTTP style).

Why #124 broke, and why this won't

#124's request body (species.plural filters + filterRadius) was rejected by the live API, which silently returned zero results — unit tests couldn't catch it. This PR uses the documented search-body shape: species.singular filters OR'd via filterProcessing, plus geodistance, in one call against the available/haspic view:

{"data": {"filters": [
    {"fieldName": "species.singular", "operation": "equal", "criteria": "dog"},
    {"fieldName": "species.singular", "operation": "equal", "criteria": "cat"}],
  "filterProcessing": "1 OR 2",
  "geodistance": {"postalcode": "02108", "miles": 50}}}

And because a wrong body fails silently, tests/test_rescue_groups_live.py (gated on CUTEPETSBOSTON_RESCUEGROUPS_API_KEY) now exists to validate the request shape against the real API — the check that would have caught #124 before merge.

Changes

  • PET_SPECIES = ("dogs", "cats") in config.py; one SourceRescueGroups fetches both in a single call (RESCUEGROUPS_LIMIT = 50)
  • Species parsed per-animal from the included species relationship; unconfigured species and the "more cats soon!" placeholder are skipped
  • Debug mode mirrors multi-species behavior with SourceManual dog + cat fixtures (tests/fixtures/sample_cats.json)
  • main.py imports moved to module level
  • New RealCaptureParsingTests parses the real API capture (tests/fixtures/sample_data.json) end-to-end as a drift guard; request-shape unit tests assert the exact filters/filterProcessing/geodistance payload and that filterRadius is gone

No website or poster changes needed — cat posts appear on cutepetsboston.org automatically once posted to Mastodon.

Test plan

  • pytest tests/ — 101 passed, 1 skipped (live test, no key)
  • python -m unittest discover -s tests — 36 passed
  • python main.py --debugsources --debugposters — fetches 27 records (25 dogs + 2 cats)
  • CUTEPETSBOSTON_RESCUEGROUPS_API_KEY=... pytest tests/test_rescue_groups_live.py — needs someone with the key before merge
  • After merge: confirm logs show a single dogs+cats fetch and a cat post appears on Mastodon within a few scheduled runs

🤖 Generated with Claude Code

@Smoss
Smoss force-pushed the smoss/multi-species-vendored-client branch from 82c547a to 31083d6 Compare July 8, 2026 00:14
@Smoss Smoss changed the title Add cats to the pet pool via the vendored RescueGroups client Add cats to the pet pool with a corrected multi-species search Jul 8, 2026
@Smoss
Smoss changed the base branch from smoss/add-rescuegroups-client to master July 8, 2026 00:14
Comment thread adoption_sources/rescue_groups.py Outdated
binamkayastha
binamkayastha previously approved these changes Jul 8, 2026

@binamkayastha binamkayastha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM - we can merge after we try testing this out for a week on the test bluesky accounts

Smoss and others added 2 commits July 14, 2026 19:37
Reimplements #124 (closes #115). #124 was reverted (#132) because its
request body -- species.plural filters plus filterRadius -- was rejected
by the live API, silently returning zero results. The body now uses the
documented search shape: species.singular filters OR'd via
filterProcessing, plus geodistance, in a single call against the
available/haspic view.

- rescue_groups.py: register one SourceRescueGroups over PET_SPECIES
  ("dogs", "cats"); parse each animal's species from the included
  species relationship; filter the "more cats soon!" placeholder.
- config.py: PET_SPECIES and RESCUEGROUPS_LIMIT (50, matching two
  per-species calls at 25 each).
- main.py: module-level imports; debug mode returns dog + cat manual
  sources backed by the new sample_cats.json fixture.
- tests: request-shape assertions (filters, filterProcessing,
  geodistance, no filterRadius), species parsing from included data,
  and RealCaptureParsingTests, which parses the real API capture in
  tests/fixtures/sample_data.json end-to-end.
- tests/test_rescue_groups_live.py: hits the real API when
  CUTEPETSBOSTON_RESCUEGROUPS_API_KEY is set -- the only check that can
  catch a request body the live API rejects, which is how #124 slipped
  through.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Reintroduces the functionality to include cats in the pet pool, correcting the request body to align with the live API's requirements. The new implementation uses singular species filters combined with geodistance in a single API call.

- Updated rescue_groups.py to handle both dogs and cats, ensuring proper species parsing.
- Adjusted config.py for PET_SPECIES and RESCUEGROUPS_LIMIT settings.
- Modified main.py for debug mode to support the new sample_cats.json.
- Enhanced tests to validate the new request shape and species parsing, including live API checks.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Smoss
Smoss force-pushed the smoss/multi-species-vendored-client branch from 42ce3b1 to a8b4862 Compare July 14, 2026 23:40

@binamkayastha binamkayastha left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTMs

@Smoss
Smoss merged commit bea20c6 into master Jul 22, 2026
2 checks passed
@Smoss
Smoss deleted the smoss/multi-species-vendored-client branch July 22, 2026 00:13
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.

Add other pets to display

2 participants