[Bug 42314] New: Add `Koha::Library->calendar`
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42314 Bug ID: 42314 Summary: Add `Koha::Library->calendar` Initiative type: --- Sponsorship --- status: Product: Koha Version: Main Hardware: All OS: All Status: NEW Severity: enhancement Priority: P5 - low Component: Architecture, internals, and plumbing Assignee: koha-bugs@lists.koha-community.org Reporter: tomascohen@gmail.com QA Contact: testopia@bugs.koha-community.org It would be handy to have such method, as calendars are always scoped to a library. It would save some includes and circular dependency risks too. -- 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=42314 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|koha-bugs@lists.koha-commun |tomascohen@gmail.com |ity.org | Status|NEW |ASSIGNED Blocks| |42311 Depends on| |42310 CC| |tomascohen@gmail.com Referenced Bugs: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42310 [Bug 42310] Move calendar CRUD to Koha::Calendar::* with normalized schema https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42311 [Bug 42311] REST API CRUD endpoints for library calendar -- 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=42314 Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Patch complexity|--- |Trivial patch Status|ASSIGNED |Needs Signoff -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42314 --- Comment #1 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 196967 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196967&action=edit Bug 42314: Add Koha::Library->calendar accessor my $calendar = $library->calendar; Returns a Koha::Calendar object for the library. Uses require to avoid circular dependency risks. 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=42314 --- Comment #2 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- Created attachment 196968 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196968&action=edit Bug 42314: (follow-up) Use Koha::Library->calendar accessor Replace direct Koha::Calendar->new calls with $library->calendar where a Koha::Library object is already available: - Koha::REST::V1::Libraries::list_closed_dates - Koha::Charges::Fees::accumulate_rentalcharge Remove now-unused 'use Koha::Calendar' from both files. 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=42314 --- Comment #3 from Tomás Cohen Arazi (tcohen) <tomascohen@gmail.com> --- In order to test this, you should: 1. Run: $ ktd --shell k$ prove t/db_dependent/Koha/Charges/Fees.t t/db_dependent/api/v1/libraries.t => SUCCESS: Tests pass! 2. Apply this patches 3. Repeat 1 => SUCCESS: Tests still pass! 4. Run: k$ prove t/db_dependent/Koha/Library.t => SUCCESS: New tests pass! 5. Sign off :-D -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42314 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=42314 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #196967|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=42314 David Nind <david@davidnind.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #196968|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=42314 --- Comment #4 from David Nind <david@davidnind.com> --- Created attachment 196976 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196976&action=edit Bug 42314: Add Koha::Library->calendar accessor my $calendar = $library->calendar; Returns a Koha::Calendar object for the library. Uses require to avoid circular dependency risks. 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=42314 --- Comment #5 from David Nind <david@davidnind.com> --- Created attachment 196977 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=196977&action=edit Bug 42314: (follow-up) Use Koha::Library->calendar accessor Replace direct Koha::Calendar->new calls with $library->calendar where a Koha::Library object is already available: - Koha::REST::V1::Libraries::list_closed_dates - Koha::Charges::Fees::accumulate_rentalcharge Remove now-unused 'use Koha::Calendar' from both files. 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=42314 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- QA Contact|testopia@bugs.koha-communit |martin.renvoize@openfifth.c |y.org |o.uk Patch complexity|Trivial patch |Small patch -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42314 Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #196976|0 |1 is obsolete| | Attachment #196977|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=42314 --- Comment #6 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 198004 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198004&action=edit Bug 42314: Add Koha::Library->calendar accessor my $calendar = $library->calendar; Returns a Koha::Calendar object for the library. Uses require to avoid circular dependency risks. 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=42314 --- Comment #7 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 198005 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198005&action=edit Bug 42314: (follow-up) Use Koha::Library->calendar accessor Replace direct Koha::Calendar->new calls with $library->calendar where a Koha::Library object is already available: - Koha::REST::V1::Libraries::list_closed_dates - Koha::Charges::Fees::accumulate_rentalcharge Remove now-unused 'use Koha::Calendar' from both files. 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=42314 --- Comment #8 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 198006 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198006&action=edit Bug 42314: (QA follow-up) Drop lazy require in Koha::Library->calendar The accessor loaded Koha::Calendar via runtime require on every call, presumably as a guard against a circular dependency. No such cycle exists: Koha::Calendar and its Koha::Calendar::* children do not use Koha::Library. Replace the runtime require with a top-level use so the module loads once at compile time, matching the other Koha::* imports in this file. Also expand the POD a little to mention what the returned Koha::Calendar is scoped to and what it is typically used for. Test plan: 1. prove t/db_dependent/Koha/Library.t 2. Check POD coverage: perl -MPod::Coverage=Koha::Library -e 1 -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42314 --- Comment #9 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 198007 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198007&action=edit Bug 42314: (follow-up) Use Koha::Library::Calendar namespace Update the calendar() accessor and its POD to point at Koha::Library::Calendar instead of the now-moved Koha::Calendar namespace, and update t/db_dependent/Koha/Library.t to match. Test plan: - prove t/db_dependent/Koha/Library.t -- You are receiving this mail because: You are watching all bug changes.
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=42314 --- Comment #10 from Martin Renvoize (ashimema) <martin.renvoize@openfifth.co.uk> --- Created attachment 198008 --> https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=198008&action=edit Bug 42314: (follow-up) Simplify list_closed_dates using closed_dates_in_range Related to Bug 42206 (which introduced the list_closed_dates controller) and Bug 42310 (which added the closed_dates_in_range accessor). The list_closed_dates controller previously reached into Koha::Calendar private state ($calendar->_holidays, $calendar->{weekly_closed_days}, $calendar->{day_month_closed_days}) to compute the closed-dates list. This broke encapsulation and would silently break if Koha::Calendar internals changed. Replace that block with a single call to the public Koha::Calendar->closed_dates_in_range accessor, chained off the Koha::Library->calendar accessor added in this bug. Test plan: 1. prove t/db_dependent/api/v1/libraries.t 2. GET /api/v1/libraries/{id}/closed_dates still returns the same list across weekly, repeating, single and exception scenarios -- You are receiving this mail because: You are watching all bug changes.
participants (1)
-
bugzilla-daemon@bugs.koha-community.org