feat(loans): consume server-localized status_label from API 1.4.3 - #30
feat(loans): consume server-localized status_label from API 1.4.3#30fabiodalez-dev wants to merge 2 commits into
Conversation
The server's /me/loans payload now ships 'status_label' — the label from Pinakes' canonical translate_loan_status() helper — and its history includes cancelled (annullato) and pickup-expired (scaduto) loans. - LoanItem gains a nullable statusLabel (null on pre-1.4.3 servers; parsing already ignores unknown keys, so this is fully additive). - StatusMapping.loan() keeps the app's own localized resources for every KNOWN state (they follow the device language, while status_label follows the server's), but for states this app version doesn't know yet the server's wording now beats the humanized snake_case guess. - LoanRow: cancelled/expired history rows no longer show a misleading "Due <date>" line — the book never went out — and fall through to the request date instead. - _contract/openapi.json mirrors the new field. Unit tests cover the server-label fallback, blank-label handling and known-state precedence (109 tests green). Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014KsK1ikTUGbUr5W3xrSJ6w
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (7)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughIl contratto OpenAPI e ChangesDati e visualizzazione dei prestiti
Estimated code review effort: 3 (Moderato) | ~20 minuti Sequence Diagram(s)sequenceDiagram
participant Server
participant LoanItem
participant LoanRow
participant StatusMapping
participant Localization
Server->>LoanItem: Fornisce status, status_label e requested_at
LoanItem->>LoanRow: Espone i dati del prestito
LoanRow->>StatusMapping: Passa status e statusLabel
StatusMapping-->>LoanRow: Restituisce il testo dello stato
LoanRow->>Localization: Recupera library_requested_on
Localization-->>LoanRow: Restituisce il testo localizzato
LoanRow-->>LoanRow: Mostra la data della richiesta
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@_contract/openapi.json`:
- Around line 733-736: Aggiorna la descrizione del campo status_label nello
schema OpenAPI per indicarlo come fallback esclusivamente per gli stati non
riconosciuti, rimuovendo l’indicazione di preferirlo alle mappe lato client.
Mantieni invariati tipo e nome della proprietà.
- Around line 733-736: Update the status_label property in the OpenAPI schema to
use the nullable OpenAPI 3.1 type declaration ["string", "null"] instead of
"string", while keeping status_label excluded from the required list.
In `@app/src/main/java/com/pinakes/app/ui/screens/library/LibraryScreen.kt`:
- Around line 211-222: Aggiorna il contratto di `/me/loans` e il modello
`LoanItem` per esporre la data richiesta, quindi aggiungi la relativa stringa
dedicata. Nel calcolo di `dateLine` in `LibraryScreen`, per gli stati
`annullato` e `scaduto` usa questa data prima dei rami `returnedAt` e `dueAt`;
non usare `loanedAt` come fallback per i prestiti mai iniziati.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro Plus
Run ID: fa80fc80-ce25-4384-bdc3-d79a162eae60
📒 Files selected for processing (5)
_contract/openapi.jsonapp/src/main/java/com/pinakes/app/data/model/Models.ktapp/src/main/java/com/pinakes/app/ui/common/StatusMapping.ktapp/src/main/java/com/pinakes/app/ui/screens/library/LibraryScreen.ktapp/src/test/java/com/pinakes/app/StatusMappingMoreTest.kt
- Contract: status_label declared nullable the OpenAPI 3.1 way (type ["string","null"]) and its description now matches the actual precedence — a fallback for states without a local mapping, while known states keep device-localized resources. - New requested_at field (API >= 1.4.3, nullable): the date the loan request was created. Cancelled/expired history rows now show "Requested <date>" instead of a misleading due/borrow line — loaned_at is the *requested start*, not a borrow date, for loans that never went out. On older servers (field absent) those rows simply show no date line. - library_requested_on added to all four i18n bundles. Full unit suite: 109 tests, 0 failures. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_014KsK1ikTUGbUr5W3xrSJ6w
|
@coderabbitai review Generated by Claude Code |
|
✅ Action performedReview finished.
|
Companion to fabiodalez-dev/Pinakes#337. The server's
/me/loansnow shipsstatus_label(the label from Pinakes' canonicaltranslate_loan_status()helper) and its history includes cancelled (annullato) and pickup-expired (scaduto) loans.The app already handled every known state in
StatusMapping— includingannullato/scaduto— so the extended history works on installed versions as-is. This PR closes the remaining gap for future states and polishes the history rows:LoanItemgains a nullablestatusLabel(status_label, null on pre-1.4.3 servers; parsing already ignores unknown keys, so the change is fully additive in both directions).StatusMapping.loan()keeps the app's own localized resources for every known state — they follow the device language, whilestatus_labelfollows the server's — but for states this app version doesn't know yet, the server's wording now beats the humanized snake_case guess.LoanRow: cancelled/expired history rows no longer show a misleading "Due <date>" line (the book never went out) and fall through to the request date instead._contract/openapi.jsonmirrors the new field.Tests: 4 new unit tests (server-label fallback, blank label ignored, known-state precedence); full unit suite 109 tests, 0 failures.
No server dependency: the app works unchanged against older servers, and older apps work unchanged against the new server.
🤖 Generated with Claude Code
https://claude.ai/code/session_014KsK1ikTUGbUr5W3xrSJ6w
Generated by Claude Code
Summary by CodeRabbit
Nuove funzionalità
Correzioni