Skip to content

feat(pet): implement computed pet availability resolver (#61)#118

Open
josealfredo79 wants to merge 2 commits into
amina69:mainfrom
josealfredo79:feat/computed-pet-availability
Open

feat(pet): implement computed pet availability resolver (#61)#118
josealfredo79 wants to merge 2 commits into
amina69:mainfrom
josealfredo79:feat/computed-pet-availability

Conversation

@josealfredo79

Copy link
Copy Markdown

Closes #61

Summary

Pet availability is now computed dynamically via PetAvailabilityService.resolve() from adoption and custody records, eliminating conflicting state.

Changes

  • PetAvailabilityService returns PetStatus enum (ADOPTED, IN_CUSTODY, PENDING, AVAILABLE) with priority rules
  • PetsService uses computed status instead of isAvailable boolean in list + single queries
  • EventLog PET_AVAILABILITY_CHANGED fired on adoption/custody transitions
  • 11 unit tests covering all states + priority overrides

Acceptance Criteria

  • Pet model contains NO status column
  • Availability is derived only
  • Unit tests for all scenarios (11 tests, all pass)
  • Used in all Pet queries (list + single)
  • EventLog created when state changes

@drips-wave

drips-wave Bot commented Jun 27, 2026

Copy link
Copy Markdown

@josealfredo79 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@amina69

amina69 commented Jun 27, 2026

Copy link
Copy Markdown
Owner

@josealfredo79 build failed, please check

@josealfredo79

Copy link
Copy Markdown
Author

@amina69 The latest commit (eeed603) fixes the DI error causing the e2e failure — PetAvailabilityService wasn't exported from PetsModule nor imported in AdoptionModule/CustodyModule. The CI run is pending approval at https://github.com/amina69/PetAd-backend/actions/runs/28300755940 — could you please approve and run it? Thanks!

@amina69

amina69 commented Jun 28, 2026

Copy link
Copy Markdown
Owner

@josealfredo79 can you refoked the branch to solve conflict issues.

- Replace boolean isAvailable with PetStatus enum (ADOPTED, IN_CUSTODY, PENDING, AVAILABLE)
- PetAvailabilityService.resolve() applies priority rules: COMPLETED > ACTIVE > PENDING > default
- Add PET_AVAILABILITY_CHANGED event type to Prisma schema + migration
- AdoptionService logs PET_AVAILABILITY_CHANGED on request, complete, reject, cancel
- CustodyService logs PET_AVAILABILITY_CHANGED on start, return, violation
- Unit tests for PetAvailabilityService covering all 4 states + priority overrides
- Update PetsService, pets tests, adoption tests, custody tests
…odule and CustodyModule

PetAvailabilityService was not exported from PetsModule and AdoptionModule
and CustodyModule were not importing PetsModule, causing DI resolution
failures in e2e tests (Nest can't resolve dependencies).
@josealfredo79 josealfredo79 force-pushed the feat/computed-pet-availability branch from eeed603 to 1c86adf Compare June 29, 2026 22:09
@josealfredo79

Copy link
Copy Markdown
Author

@amina69 Ok

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.

Pet Availability Resolver (Computed State)

3 participants