Skip to content

Show the return date of a loan request, not "about a month" - #51

Closed
fabiodalez-dev wants to merge 9 commits into
mainfrom
ccr-8d8cddaa-n6j61l
Closed

fabiodalez-dev wants to merge 9 commits into
mainfrom
ccr-8d8cddaa-n6j61l

Conversation

@fabiodalez-dev

@fabiodalez-dev fabiodalez-dev commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Android counterpart of fabiodalez-dev/Pinakes#485, which now also exposes the loan duration to the app (Mobile API 1.8.1).

What changes

Under the calendar, the loan-request dialog said the loan would last "about 1 month" from the chosen day. The server sets the return date from the loan duration in the library's loan settings (loan_duration_days, 30 by default). It does this on POST /reservations (UserActionsController::loan() / reserve()), the same way the website does. So a library with a 14- or 60-day loan period saw a wrong promise.

  • With Mobile API 1.8.1: GET /catalog/books/{id}/availability returns loan_duration_days. AvailabilityCalendar reads it, and the dialog shows "Start: · Return by: " for the selected day (it/en/fr/de, new key book_loan_period_range).
  • Older servers (field absent): book_loan_period_hint now refers to the library's standard loan period instead of "about 1 month". The wording matches staff_loan_dates_hint.
  • The KDoc/comments that described the return as "+1 month" now describe the configured duration.
  • LoanRequestReturnDateTest (Robolectric) covers the date arithmetic, parsing with and without the field, and both dialog texts.

The app only sends desired_date, so the web bug fixed in #485 (an untouched request became a one-day loan) never affected it.

Other PRs reviewed, nothing to port

  • #483 (htaccess-heal-old-formats): .htaccess heal and the plugin-hook fix on the server. The app gets digital files through the API.
  • #486 (seo-public-pages): sitemap, meta/OG tags and the /i18n/{locale}.js script of the web layouts. The app doesn't use them.
  • #487 (mail-template-descriptions): descriptions in the mail template editor. The app has no template editor.

Testing

  • The four i18n/*.json files parse as valid JSON and have the same keys.
  • I couldn't run Gradle in the session's container because Maven Central returned HTTP 429 while resolving the Android Gradle Plugin. CI runs unit tests, lint and both assemble variants.

Summary by CodeRabbit

  • Nuove funzionalità

    • Mostrata la data prevista di restituzione in base alla durata del prestito configurata dalla biblioteca, quando disponibile.
    • Mantenuto un suggerimento standard quando la durata non viene fornita dal server.
  • Miglioramenti

    • Aggiornate le traduzioni in inglese, tedesco, francese e italiano per descrivere correttamente il periodo di prestito e l’intervallo tra inizio e restituzione.
  • Test

    • Aggiunti test per il calcolo, la visualizzazione e la gestione dei dati di durata del prestito.

Calendar conflict resolution and verification

Merged PR #46's updated calendar so the styled sheet and the configured return-date hint coexist. The return date uses this PR's newer server-provided loan_duration_days; the shared fallback grid, locale handling and responsive layout from current main are preserved. Merge #46 before this PR.

All four open Android PRs combined pass 411 debug and 411 release unit tests, with no failures or skips. This includes the 15 new calendar regression tests and the existing return-date tests. compileDebugAndroidTestKotlin also passes; no device execution was performed during this review.

The sheet is a plain dialog instead of DatePickerDialog, which capped its
height and cut the month in half: 20dp corners, a Fraunces title, confirm
and cancel stacked at full width in the app's button styles.

The month follows the web: a free day is a plain number, limited and
unavailable days keep their tint with a faint rule of their own colour,
today has an accent ring and the chosen day takes the theme's button
colour. The legend uses dots.

When availability cannot be loaded, the fallback Material picker takes
the sheet's side padding too: on a 360dp phone its seventh column was
otherwise cut in half.

LoanRequestSheetUiTest covers the buttons, the pre-selected earliest day,
the disabled states and the seventh column at 360dp (verified to fail
without the fix). DESIGN.md documents the sheet.
The test forced a 360dp density around LoanRequestSheet, but a Dialog is a
window of its own and takes the device density: on a 411dp emulator the
days measured 42dp instead of 48dp, so the test only held on an emulator
that was already 360dp wide.

The sheet's content moves into LoanRequestSheetContent, which the Dialog
wraps; the test lays it out in a 360dp Box at the device density. It fails
without the bleed (24dp of a 40dp day in view) and passes with it on both
a 360dp and a 411dp emulator.
The loan-request dialog said the loan would last "about 1 month" from the chosen day. The
server sets the return date from the loan duration in the library's loan settings
(loan_duration_days, 30 by default), on POST /reservations as on the website, so a library
with a 14 or 60 day period saw a wrong promise. Pinakes #485 made the website's return picker
open on that same duration; the app now names the library's standard loan period in all four
languages, the way the staff new-loan form already does. The comments that described the
return as +1 month say the same.
@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 1c783423-157c-4e6c-90b4-04139e0fe3b1

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a9fca16d-bbef-476e-8baf-84f70e665cd8
📥 Commits

Reviewing files that changed from the base of the PR and between f0a712a and a00945f.

📒 Files selected for processing: 9
  • app/src/main/java/com/pinakes/app/data/model/Models.kt
  • app/src/main/java/com/pinakes/app/data/repository/LibraryRepository.kt
  • app/src/main/java/com/pinakes/app/ui/screens/detail/BookDetailScreen.kt
  • app/src/main/java/com/pinakes/app/ui/screens/detail/BookDetailViewModel.kt
  • app/src/test/java/com/pinakes/app/LoanRequestReturnDateTest.kt
  • i18n/de.json
  • i18n/en.json
  • i18n/fr.json
  • i18n/it.json

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

Walkthrough

Il calendario della disponibilità ora include la durata del prestito configurata dalla biblioteca. Il dialogo della richiesta mostra la data di restituzione prevista quando può calcolarla. Se la durata manca, mantiene il suggerimento standard.

Changes

Durata del prestito nella richiesta

Layer / File(s) Summary
Contratto del calendario e documentazione
app/src/main/java/com/pinakes/app/data/model/Models.kt, app/src/main/java/com/pinakes/app/data/repository/LibraryRepository.kt, app/src/main/java/com/pinakes/app/ui/screens/detail/BookDetailViewModel.kt
AvailabilityCalendar aggiunge il campo nullable loanDurationDays, letto da loan_duration_days. La documentazione descrive la data di restituzione come determinata dalla durata configurata dalla biblioteca.
Calcolo e visualizzazione della data
app/src/main/java/com/pinakes/app/ui/screens/detail/BookDetailScreen.kt, app/src/test/java/com/pinakes/app/LoanRequestReturnDateTest.kt, i18n/*.json
La schermata calcola la data di restituzione dalla data iniziale e dalla durata disponibile. Se la durata manca o l’input non è valido, non mostra una data calcolata. I test verificano il calcolo, il parsing JSON e il testo del dialogo; le traduzioni aggiornano il suggerimento standard e aggiungono l’etichetta dell’intervallo.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~12 minutes

Change: Bug fix

Merge Risk: ⚪ Minimal · up to a0094

The loan dialog shows the return date for the selected start date. No identified issue blocks merge after normal checks.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 5 files. (4 skipped: … Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description Check Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check Passed Il titolo descrive in modo chiaro la modifica principale: mostrare la data di restituzione invece dell’indicazione generica "about a month".
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.
Full details: Docstring Coverage

Explanation

Docstring coverage is 45.45% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 11 functions across 5 files. (4 skipped: 4 unsupported.)

Resolution

Write docstrings for the functions missing them to satisfy the coverage threshold.

✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

Sono un coniglio, conto i giorni con cura,
quattordici salti, una data futura.
Se il calendario offre la durata,
mostro il ritorno nella schermata.
Se non la trovo, resto tranquillo,
e lascio il suggerimento sul mio foglietto.

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

Mobile API 1.8.1 (Pinakes #485) adds loan_duration_days to GET
/catalog/books/{id}/availability: the days POST /reservations adds to the chosen start to set
the return date. The dialog now reads "Start: <date> · Return by: <date>" for the selected
day, in all four languages. A server that does not send the field keeps the wording about the
library's standard loan period.

LoanRequestReturnDateTest covers the date arithmetic, the parsing with and without the field,
and both dialog texts.
@fabiodalez-dev fabiodalez-dev changed the title Say the loan request lasts the library's loan period, not about a month Show the return date of a loan request, not "about a month" Oct 20, 2026
@fabiodalez-dev
fabiodalez-dev marked this pull request as ready for review October 20, 2026 17:41

fabiodalez-dev commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 20, 2026 •

Copy link
Copy Markdown
✅ 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.

@pullfrog pullfrog 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.

✅ No new issues found.

Reviewed changes

I reviewed the whole PR: the loan-request dialog now shows the real return date when the server sends the loan duration, and a neutral message on older servers.

  • loan_duration_days on availability: AvailabilityCalendar.loanDurationDays is nullable, so servers older than Mobile API 1.8.1 still decode cleanly.
  • Return-date hint: loanReturnDate adds the duration to the chosen start. LoanRequestSheet shows book_loan_period_range when it gets a date and falls back to the reworded book_loan_period_hint when it doesn't. I checked this against UserActionsController::reserve() on the server, which computes start + {loanDays} days with no off-by-one and rejects durations below 1. The app's < 1 → null guard matches that.
  • Copy and docs: The new and reworded strings are in all four i18n/*.json files with no em dashes. The "+1 month" KDoc/comments now describe the configured duration.
  • Tests: LoanRequestReturnDateTest covers the arithmetic, parsing with and without the field, and both dialog texts. It includes the addActivityIfNotPresent RuleChain it needs to pass under testReleaseUnitTest.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

CodeRabbit's docstring check counted the test methods and the show() helper of
LoanRequestReturnDateTest as undocumented (45% against the 80% threshold). Each now says
what it pins down. Comments only.

@pullfrog pullfrog 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.

ℹ️ No functional issues in the merge. One minor doc note inline.

Reviewed changes

Since the last review (a00945f), this PR merged in #46's restyled loan sheet and added regression tests. The server-based return date survives the merge.

  • Sheet split: LoanRequestSheet now wraps a new LoanRequestSheetContent in the Dialog. That lets tests lay it out at a fixed width. The pre-existing CalendarLayoutTest still finds loan-dialog, which is now on the Box around the sheet.
  • Buttons: the old TextButton row is replaced by a stacked PrimaryButton/SecondaryButton. Confirm stays disabled until a day is picked and while the request is sent, because loading = submitting also disables the button.
  • Merged hint: the return-date hint is unchanged from the reviewed version. It shows book_loan_period_range when the server sends loan_duration_days and the reworded book_loan_period_hint when it doesn't.
  • Calendar styling: in LoanCalendar.kt, free days are no longer tinted. Partial and full days get a ring mixed from their own text colour, and the selected day uses the theme's button/buttonText. The legend now uses dots.
  • Tests: added LoanCalendarRegressionTest (15 Robolectric tests, with the addActivityIfNotPresent RuleChain needed under release) and LoanRequestSheetUiTest (4 device tests). I checked the edge cases. The past-day test still works on the 1st of a month because the grid opens on the earliestAvailable month.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread STATUS.md Outdated
@fabiodalez-dev
fabiodalez-dev deleted the ccr-8d8cddaa-n6j61l branch October 21, 2026 07:52
fabiodalez-dev added a commit that referenced this pull request Oct 21, 2026
Bumps the version and records in STATUS what 1.9.0 brings: closed digital files with their reason and signed-link renewal (#50), the restyled loan request sheet (#46), the return date from the server's loan duration (#51) and the wanted-title receive action (#49).
@fabiodalez-dev

Copy link
Copy Markdown
Owner Author

This change ships in 1.9.0: its head (5ccd695) is merged into release/1.9.0 through #52, unchanged. The PR shows as closed only because I renamed its branch to fix/loan-request-return-date.

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.

1 participant