Skip to content

feat(loans): consume server-localized status_label from API 1.4.3 - #30

Open
fabiodalez-dev wants to merge 2 commits into
mainfrom
claude/loan-status-label
Open

feat(loans): consume server-localized status_label from API 1.4.3#30
fabiodalez-dev wants to merge 2 commits into
mainfrom
claude/loan-status-label

Conversation

@fabiodalez-dev

@fabiodalez-dev fabiodalez-dev commented Aug 11, 2026

Copy link
Copy Markdown
Owner

Companion to fabiodalez-dev/Pinakes#337. The server's /me/loans now ships status_label (the label from Pinakes' canonical translate_loan_status() helper) and its history includes cancelled (annullato) and pickup-expired (scaduto) loans.

The app already handled every known state in StatusMapping — including annullato/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:

  • LoanItem gains a nullable statusLabel (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, 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.

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à

    • Le etichette degli stati dei prestiti possono ora essere fornite dal server e visualizzate in forma localizzata.
    • Gli stati non riconosciuti mostrano l’etichetta disponibile dal server, con un fallback leggibile.
    • Le informazioni sulla data della richiesta sono disponibili quando fornite.
  • Correzioni

    • Migliorata la visualizzazione dei prestiti annullati o scaduti: non viene più mostrata una scadenza non pertinente.
    • Per questi prestiti viene utilizzata, quando disponibile, la data della richiesta.

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
@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c0c57963-6ea2-4e62-b127-a9bb897fa7f9

📥 Commits

Reviewing files that changed from the base of the PR and between feef35c and fc5fd16.

📒 Files selected for processing (7)
  • _contract/openapi.json
  • app/src/main/java/com/pinakes/app/data/model/Models.kt
  • app/src/main/java/com/pinakes/app/ui/screens/library/LibraryScreen.kt
  • i18n/de.json
  • i18n/en.json
  • i18n/fr.json
  • i18n/it.json
🚧 Files skipped from review as they are similar to previous changes (3)
  • app/src/main/java/com/pinakes/app/ui/screens/library/LibraryScreen.kt
  • _contract/openapi.json
  • app/src/main/java/com/pinakes/app/data/model/Models.kt

Walkthrough

Il contratto OpenAPI e LoanItem aggiungono status_label e requested_at. La mappatura usa l’etichetta server per gli stati sconosciuti. LoanRow mostra la data della richiesta per prestiti annullati o scaduti. Le traduzioni e i test coprono il nuovo comportamento.

Changes

Dati e visualizzazione dei prestiti

Layer / File(s) Summary
Contratto e modello dei dati
_contract/openapi.json, app/src/main/java/com/pinakes/app/data/model/Models.kt
LoanItem aggiunge statusLabel e requestedAt come campi nullable. Il contratto espone gli stessi dati come status_label e requested_at.
Mappatura degli stati
app/src/main/java/com/pinakes/app/ui/common/StatusMapping.kt, app/src/test/java/com/pinakes/app/StatusMappingMoreTest.kt
Gli stati sconosciuti usano un’etichetta server non vuota. Gli stati noti mantengono la risorsa localizzata. I test verificano entrambi i percorsi.
Visualizzazione delle date
app/src/main/java/com/pinakes/app/ui/screens/library/LibraryScreen.kt, i18n/*.json
LoanRow mostra la data della richiesta per gli stati annullato e scaduto. Le traduzioni aggiungono library_requested_on in tedesco, inglese, francese e italiano.

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
Loading

Poem

Sono un coniglio ben informato,
con lo stato localizzato.
Se la richiesta è già scaduta,
la sua data viene mostrata.
Un’etichetta dal server arriva,
e la riga subito la attiva.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed Il titolo descrive chiaramente il cambiamento principale: il supporto a status_label localizzato dal server nell'API 1.4.3.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/loan-status-label

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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

📥 Commits

Reviewing files that changed from the base of the PR and between 050d4b5 and feef35c.

📒 Files selected for processing (5)
  • _contract/openapi.json
  • app/src/main/java/com/pinakes/app/data/model/Models.kt
  • app/src/main/java/com/pinakes/app/ui/common/StatusMapping.kt
  • app/src/main/java/com/pinakes/app/ui/screens/library/LibraryScreen.kt
  • app/src/test/java/com/pinakes/app/StatusMappingMoreTest.kt

Comment thread _contract/openapi.json
Comment thread app/src/main/java/com/pinakes/app/ui/screens/library/LibraryScreen.kt Outdated
- 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

Copy link
Copy Markdown
Owner Author

@coderabbitai review


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Aug 11, 2026

Copy link
Copy Markdown

@fabiodalez-dev I will review the changes in #30.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

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.

2 participants