Skip to content

feat: implement Infra layer for favorite heritages list API / お気に入り一覧APIのInfra層実装 - #564

Merged
zigzagdev merged 2 commits into
feat/user-favoritefrom
feat/user-favorite-index-list-infra
Aug 8, 2026
Merged

feat: implement Infra layer for favorite heritages list API / お気に入り一覧APIのInfra層実装#564
zigzagdev merged 2 commits into
feat/user-favoritefrom
feat/user-favorite-index-list-infra

Conversation

@zigzagdev

@zigzagdev zigzagdev commented Aug 8, 2026

Copy link
Copy Markdown
Owner

Motivation / 目的

Add the Infra layer support needed for a "list my favorite heritages" API: a way to fetch the world heritage site ids a user has favorited, reusing the existing favorites() relation added for addFavorite().

What I have done / 実施内容

  • Added FavoriteRepositoryInterface::getFavoriteWorldHeritageIds(int $userId): array
  • Implemented it in FavoriteRepository, returning world heritage site ids ordered by most recently favorited first, throwing Exception('User not found.') when the user doesn't exist (same convention as addFavorite)
  • Added withTimestamps() to User::favorites() so pivot created_at is populated on attach(), which the new method orders by
  • Added integration tests against the real test database

Test Results / テスト結果

  • test_getFavoriteWorldHeritageIds_returns_ids_ordered_by_most_recently_favorited
  • test_getFavoriteWorldHeritageIds_returns_empty_array_when_no_favorites
  • test_getFavoriteWorldHeritageIds_throws_exception_when_user_not_found

Closes #566

@codecov

codecov Bot commented Aug 8, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 63.70%. Comparing base (c293a43) to head (b4acd34).

Additional details and impacted files

Impacted file tree graph

@@                   Coverage Diff                    @@
##             feat/user-favorite     #564      +/-   ##
========================================================
+ Coverage                 63.59%   63.70%   +0.10%     
- Complexity                 1652     1657       +5     
========================================================
  Files                       142      142              
  Lines                      8582     8607      +25     
========================================================
+ Hits                       5458     5483      +25     
  Misses                     3124     3124              
Files with missing lines Coverage Δ
src/app/Models/User.php 100.00% <100.00%> (ø)
...p/Packages/Domains/Favorite/FavoriteRepository.php 100.00% <100.00%> (ø)
.../Domains/Favorite/Tests/FavoriteRepositoryTest.php 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@zigzagdev zigzagdev left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

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

OK

@zigzagdev
zigzagdev merged commit 5e2a643 into feat/user-favorite Aug 8, 2026
28 checks passed
@zigzagdev
zigzagdev deleted the feat/user-favorite-index-list-infra branch August 8, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: implement Infra layer for favorite heritages list API / お気に入り一覧APIのInfra層実装

1 participant