Repository navigation
Commit 9c49356
refactor: deepen Deck and Card data-access modules (#51)
* refactor: deepen Deck and Card data-access modules
The DecksRepository / CardsRepository were empty subclasses of
advanced-alchemy's service, so their interface was the entire generic
surface and the query knowledge — filters, eager-load options,
schema→model mapping — leaked into every HTTP handler.
Deepen both modules with a small set of named methods that absorb that
knowledge behind the interface:
- DecksRepository.fetch_with_cards — id filter + selectinload(cards)
- CardsRepository.list_for_deck — deck_id filter
- CardsRepository.add_cards — model_dump + deck_id + Card(...) build
- CardsRepository.upsert_cards — same mapping, upsert semantics
Handlers now name the intent and hand over the request schemas they
already hold. Additive only: advanced-alchemy's generic surface stays
visible so the template still demonstrates the library. Behaviour is
unchanged — fetch_with_cards returns Deck | None and the existing 404
path is byte-for-byte the same.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* update packages
---------
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent af2be40 commit 9c49356
3 files changed
Lines changed: 333 additions & 317 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
3 | 3 | | |
4 | 4 | | |
5 | 5 | | |
6 | | - | |
7 | 6 | | |
8 | 7 | | |
9 | 8 | | |
| |||
26 | 25 | | |
27 | 26 | | |
28 | 27 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
| 28 | + | |
33 | 29 | | |
34 | 30 | | |
35 | 31 | | |
| |||
64 | 60 | | |
65 | 61 | | |
66 | 62 | | |
67 | | - | |
| 63 | + | |
68 | 64 | | |
69 | 65 | | |
70 | 66 | | |
| |||
85 | 81 | | |
86 | 82 | | |
87 | 83 | | |
88 | | - | |
89 | | - | |
90 | | - | |
| 84 | + | |
91 | 85 | | |
92 | 86 | | |
93 | 87 | | |
| |||
97 | 91 | | |
98 | 92 | | |
99 | 93 | | |
100 | | - | |
101 | | - | |
102 | | - | |
| 94 | + | |
103 | 95 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
1 | 3 | | |
2 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
3 | 8 | | |
4 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
5 | 12 | | |
6 | 13 | | |
7 | 14 | | |
| |||
10 | 17 | | |
11 | 18 | | |
12 | 19 | | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
13 | 26 | | |
14 | 27 | | |
15 | 28 | | |
16 | 29 | | |
17 | 30 | | |
18 | 31 | | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
0 commit comments