fix(decks): support faction & hero filters on GET /api/decks - #50
Merged
Conversation
The "My Decks" tab (GET /api/decks) is served by the custom DeckCollectionProvider, which bypasses API Platform's filter system, so the faction/hero query params were silently ignored and every deck was returned regardless of the selected filter. Only /api/decks/public (a separate custom controller) honoured them. The provider now reads faction/hero from the request and delegates to a new DeckRepository::findByUser(), reusing the exact jsonb matching used by the public listing (faction = reference part 4; hero normalised to parts 4+5 so the same hero matches across sets/rarities). The public listing's hero/faction WHERE building is extracted into a shared buildHeroFactionWhere() helper to keep both paths in sync. Adds regression tests for faction and cross-set hero filtering. Disables kernel reboot in the DeckTest setup so successive POSTs with distinct mocked card data work (fixes a latent test-harness issue where the mock was reset between requests). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- Read faction/hero from API Platform's $context['filters'] instead of injecting RequestStack; ignore non-scalar/empty params so they can't reach the string-typed repository method. - Make DeckCollectionProvider a final readonly class (matches DeckItemProvider). - Extract a shared fetchDecks() native-query helper, reused by findPublic, findByUser and findBgaDecks. - Clear cache.app in the test's mockAlteredCore() so re-mocking the same card reference takes effect now that kernel reboot is disabled. - Add tests: combined faction+hero (AND), no-match, case sensitivity, and cross-user isolation. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problème
Sur l'onglet « Mes decks » du site, les filtres faction et héros n'avaient aucun effet : tous les decks étaient renvoyés quel que soit le filtre sélectionné.
GET /api/decksest servi par le provider customDeckCollectionProvider, qui court-circuite le système de filtres d'API Platform. Les query paramsfaction/hero(déjà envoyés correctement par le site) étaient donc silencieusement ignorés. Seul/api/decks/public(contrôleur custom séparé) les gérait — d'où le fait que le filtrage marchait sur l'onglet « Communauté » mais pas sur « Mes decks ».Correctif
DeckCollectionProviderlit désormaisfaction/herodepuis la requête et délègue à une nouvelle méthodeDeckRepository::findByUser()(scope au user courant préservé).findByUser()réutilise exactement le matching jsonb du listing public : faction = partie 4 de la référence du héros ; héros normalisé sur les parties 4+5, donc un même héros matche à travers les sets/raretés. La construction du WHERE hero/faction est extraite dans un helper partagébuildHeroFactionWhere()pour garder les deux chemins synchronisés.Tests
disableReboot()ajouté dans lesetUpdeDeckTest: corrige un souci latent du harnais où le reboot du kernel réinitialisait le mock entre deux POST successifs (bloquait tout test multi-POST avec des cartes mockées différentes).Vérifications
bin/phpunit: 45/45 tests (nouveaux + existants)Côté site
Aucun changement nécessaire dans
alteredcore-website: le proxy envoie déjàfaction/hero. Une fois cette API déployée, « Mes decks » filtrera comme « Communauté ».🤖 Generated with Claude Code