[Bug 42206] New: Add REST endpoint GET /libraries/{id}/holidays
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Bug ID: 42206 Summary: Add REST endpoint GET /libraries/{id}/holidays Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: REST API Assignee: koha-bugs@lists.koha-community.org Reporter: paul.derscheid@lmscloud.de QA Contact: testopia@bugs.koha-community.org CC: tomascohen@gmail.com There is currently no API endpoint to retrieve closed days for a library. This makes it difficult for frontend components (e.g. bookings) to determine which dates a library is closed without server-side rendering. This patch adds a GET /api/v1/libraries/{library_id}/holidays endpoint that returns a list of xholiday dates (YYYY-MM-DD) for a given library within an optional date range, using Koha::Calendar. Defaults to today + 3 months if no range is specified. Returns 400 if the to date precedes from, and 404 if the library does not exist. -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Comma delimited| |Büchereizentrale list of Sponsors| |Schleswig-Holstein | |<https://www.bz-sh.de/> Sponsorship status|--- |Sponsored Status|NEW |Needs Signoff -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 --- Comment #1 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Created attachment 196432 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196432&action=edit Bug 42206: Add GET /libraries/{id}/holidays endpoint - Add list_holidays controller to Koha::REST::V1::Libraries - Returns closed days for a library within a configurable date range - Uses Koha::Calendar to determine holidays - Defaults to today + 3 months if no range specified - Add OpenAPI spec for the new endpoint - Register route in swagger.yaml - Add unit tests in t/db_dependent/api/v1/libraries.t To test: 1. Apply patch 2. prove t/db_dependent/api/v1/libraries.t 3. Verify all tests pass, including the new list_holidays subtest which covers: - Holidays returned within a specified date range - Empty list when no holidays exist in range - 400 response when 'to' date precedes 'from' date - 404 response for non-existent library - Default range (no params) returns successfully Sponsored-by: Büchereizentrale Schleswig-Holstein <https://www.bz-sh.de/> -- You are receiving this mail because: You are watching all bug changes. You are the assignee for the bug.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |paul.derscheid@lmscloud.de |ity.org | Comma delimited|Büchereizentrale |Büchereizentrale list of Sponsors|Schleswig-Holstein |Schleswig-Holstein |<https://www.bz-sh.de/> |<https://www.bz-sh.de/> -- You are receiving this mail because: You are the assignee for the bug. You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |41129 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=41129 [Bug 41129] Migrate place_booking.js to a Vue island. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |tomascohen@gmail.com |y.org | Comma delimited|Büchereizentrale |Büchereizentrale list of Sponsors|Schleswig-Holstein |Schleswig-Holstein |<https://www.bz-sh.de/> |<https://www.bz-sh.de/>, | |Büchereizentrale | |Schleswig-Holstein | |<https://www.bz-sh.de/> Patch complexity|--- |Small patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #196432|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 --- Comment #2 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 196937 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196937&action=edit Bug 42206: Add GET /libraries/{id}/holidays endpoint - Add list_holidays controller to Koha::REST::V1::Libraries - Returns closed days for a library within a configurable date range - Uses Koha::Calendar to determine holidays - Defaults to today + 3 months if no range specified - Add OpenAPI spec for the new endpoint - Register route in swagger.yaml - Add unit tests in t/db_dependent/api/v1/libraries.t To test: 1. Apply patch 2. prove t/db_dependent/api/v1/libraries.t 3. Verify all tests pass, including the new list_holidays subtest which covers: - Holidays returned within a specified date range - Empty list when no holidays exist in range - 400 response when 'to' date precedes 'from' date - 404 response for non-existent library - Default range (no params) returns successfully Sponsored-by: Büchereizentrale Schleswig-Holstein <https://www.bz-sh.de/> Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 --- Comment #3 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 196938 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196938&action=edit Bug 42206: (follow-up) Rename to /closed_dates, improve efficiency Rename /libraries/{id}/holidays to /libraries/{id}/closed_dates for consistency with existing sub-resource naming (desks, cash_registers). Efficiency: instead of calling $calendar->is_holiday() per day (which re-checks all three data sources each time), access the pre-loaded data structures directly: weekly_closed_days array, day_month_closed_days hash, and _holidays hash. The logic properly handles exceptions (dates marked open despite a weekly/annual closure). Additional fixes: - Add 365-day max range guard - Add missing 401/403 responses in swagger spec - Add request_id_header parameter - Test exception handling (open on normally-closed day) - Remove fragile 'empty defaults' assertion Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 --- Comment #4 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Please review my follow-up and let me know if you agree with it. I know it implies changes to the development that uses it, but should be minor. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Comma delimited|Büchereizentrale |Büchereizentrale list of Sponsors|Schleswig-Holstein |Schleswig-Holstein |<https://www.bz-sh.de/>, |<https://www.bz-sh.de/>, |Büchereizentrale |Büchereizentrale |Schleswig-Holstein |Schleswig-Holstein |<https://www.bz-sh.de/> |<https://www.bz-sh.de/> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|Add REST endpoint GET |Add REST endpoint GET |/libraries/{id}/holidays |/libraries/{library_id}/clo | |sed_dates -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |martin.renvoize@openfifth.c | |o.uk --- Comment #5 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- *** Bug 39486 has been marked as a duplicate of this bug. *** -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Paul Derscheid <paul.derscheid@lmscloud.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #196938|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 --- Comment #6 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Created attachment 196941 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196941&action=edit Bug 42206: (follow-up) Rename to /closed_dates, improve efficiency Rename /libraries/{id}/holidays to /libraries/{id}/closed_dates for consistency with existing sub-resource naming (desks, cash_registers). Efficiency: instead of calling $calendar->is_holiday() per day (which re-checks all three data sources each time), access the pre-loaded data structures directly: weekly_closed_days array, day_month_closed_days hash, and _holidays hash. The logic properly handles exceptions (dates marked open despite a weekly/annual closure). Additional fixes: - Add 365-day max range guard - Add missing 401/403 responses in swagger spec - Add request_id_header parameter - Test exception handling (open on normally-closed day) - Remove fragile 'empty defaults' assertion Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 --- Comment #7 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Hi Tómas, thanks so much for the follow-up. That's much better, only thing I stumbled upon was the variable name $dominated, but I can't think of any other better var name right now, maybe $is_closed or something, then 1 is closed and 0 open? -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 --- Comment #8 from Paul Derscheid <paul.derscheid@lmscloud.de> --- Sorry, Tomás 😅. -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Blocks| |42310 Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42310 [Bug 42310] Move calendar CRUD to Koha::Calendar::* with normalized schema -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Needs Signoff |Signed Off -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #196937|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #196941|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 --- Comment #9 from David Nind <david@davidnind.com> --- Created attachment 196969 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196969&action=edit Bug 42206: Add GET /libraries/{id}/holidays endpoint - Add list_holidays controller to Koha::REST::V1::Libraries - Returns closed days for a library within a configurable date range - Uses Koha::Calendar to determine holidays - Defaults to today + 3 months if no range specified - Add OpenAPI spec for the new endpoint - Register route in swagger.yaml - Add unit tests in t/db_dependent/api/v1/libraries.t To test: 1. Apply patch 2. prove t/db_dependent/api/v1/libraries.t 3. Verify all tests pass, including the new list_holidays subtest which covers: - Holidays returned within a specified date range - Empty list when no holidays exist in range - 400 response when 'to' date precedes 'from' date - 404 response for non-existent library - Default range (no params) returns successfully Sponsored-by: Büchereizentrale Schleswig-Holstein <https://www.bz-sh.de/> Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 --- Comment #10 from David Nind <david@davidnind.com> --- Created attachment 196970 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196970&action=edit Bug 42206: (follow-up) Rename to /closed_dates, improve efficiency Rename /libraries/{id}/holidays to /libraries/{id}/closed_dates for consistency with existing sub-resource naming (desks, cash_registers). Efficiency: instead of calling $calendar->is_holiday() per day (which re-checks all three data sources each time), access the pre-loaded data structures directly: weekly_closed_days array, day_month_closed_days hash, and _holidays hash. The logic properly handles exceptions (dates marked open despite a weekly/annual closure). Additional fixes: - Add 365-day max range guard - Add missing 401/403 responses in swagger spec - Add request_id_header parameter - Test exception handling (open on normally-closed day) - Remove fragile 'empty defaults' assertion Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Signed-off-by: David Nind <david@davidnind.com> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Comma delimited|Büchereizentrale |Büchereizentrale list of Sponsors|Schleswig-Holstein |Schleswig-Holstein |<https://www.bz-sh.de/>, |<https://www.bz-sh.de/> |Büchereizentrale | |Schleswig-Holstein | |<https://www.bz-sh.de/> | CC| |david@davidnind.com -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |me@paulderscheid.xyz -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|Signed Off |Passed QA QA Contact|tomascohen@gmail.com |martin.renvoize@openfifth.c | |o.uk -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #196969|0 |1 is obsolete| | Attachment #196970|0 |1 is obsolete| | -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 --- Comment #11 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 197987 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=197987&action=edit Bug 42206: Add GET /libraries/{id}/holidays endpoint - Add list_holidays controller to Koha::REST::V1::Libraries - Returns closed days for a library within a configurable date range - Uses Koha::Calendar to determine holidays - Defaults to today + 3 months if no range specified - Add OpenAPI spec for the new endpoint - Register route in swagger.yaml - Add unit tests in t/db_dependent/api/v1/libraries.t To test: 1. Apply patch 2. prove t/db_dependent/api/v1/libraries.t 3. Verify all tests pass, including the new list_holidays subtest which covers: - Holidays returned within a specified date range - Empty list when no holidays exist in range - 400 response when 'to' date precedes 'from' date - 404 response for non-existent library - Default range (no params) returns successfully Sponsored-by: Büchereizentrale Schleswig-Holstein <https://www.bz-sh.de/> Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 --- Comment #12 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 197988 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=197988&action=edit Bug 42206: (follow-up) Rename to /closed_dates, improve efficiency Rename /libraries/{id}/holidays to /libraries/{id}/closed_dates for consistency with existing sub-resource naming (desks, cash_registers). Efficiency: instead of calling $calendar->is_holiday() per day (which re-checks all three data sources each time), access the pre-loaded data structures directly: weekly_closed_days array, day_month_closed_days hash, and _holidays hash. The logic properly handles exceptions (dates marked open despite a weekly/annual closure). Additional fixes: - Add 365-day max range guard - Add missing 401/403 responses in swagger spec - Add request_id_header parameter - Test exception handling (open on normally-closed day) - Remove fragile 'empty defaults' assertion Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io> Signed-off-by: Paul Derscheid <paul.derscheid@lmscloud.de> Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk> -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Lucas Gass (lukeg) <lucas@bywatersolutions.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)| |26.05.00 released in| | Status|Passed QA |Pushed to main -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 --- Comment #13 from Lucas Gass (lukeg) <lucas@bywatersolutions.com> --- Nice work everyone! Pushed to main for 26.05 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Jacob O'Mara <jacob.omara@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Version(s)|26.05.00 |26.05.00,25.11.05 released in| | Status|Pushed to main |Pushed to stable -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 --- Comment #14 from Jacob O'Mara <jacob.omara@openfifth.co.uk> --- Thanks all, pushed to 25.11.x -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |wainuiwitikapark@catalyst.n | |et.nz Status|Pushed to stable |Needs documenting --- Comment #15 from Wainui Witika-Park <wainuiwitikapark@catalyst.net.nz> --- Enhancement - not backporting to 25.05 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42206 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Resolution|--- |FIXED Status|Needs documenting |RESOLVED --- Comment #16 from David Nind <david@davidnind.com> --- API-related, no changes required to the manual. -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org