Hours of Operation Refactor
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Evergreen |
New
|
Undecided
|
Unassigned |
Bug Description
While working on lp1396764, I encountered some unexpected challenges relating to the design of the Org Unit Hours of Operation object. At the moment, its fields are structured like this:
<fields oils_persist:
<field name="dow_0_close" />
<field name="dow_0_open" />
<field name="dow_1_close" />
<field name="dow_1_open" />
<field name="dow_2_close" />
<field name="dow_2_open" />
<field name="dow_3_close" />
<field name="dow_3_open" />
<field name="dow_4_close" />
<field name="dow_4_open" />
<field name="dow_5_close" />
<field name="dow_5_open" />
<field name="dow_6_close" />
<field name="dow_6_open" />
<field name="id" reporter:
<field name="org_unit" oils_persist:
</fields>
This ends up with a lot of bloat, especially in cases where we want to add fields to the Hours of Operation. The OPAC UI displaying hours of operation has to go through each day of the week manually, and the Angular UI to edit them is also fairly clunky in how it iterates through each day of the week.
I'd propose changing it over to something a bit more simple and workable:
<fields oil persist:
<field name="open">
<field name="close">
<field name="day_of_week">
<field name="id">
<field name="org_unit">
</fields>
When referencing an Org Unit's Hours of Operation, we would grab all 'auhoo' objects referencing the chosen Org Unit, listed out by day of the week in an order based on the "open" time. This also eases the ability to add additional fields to the object, such as notes (mentioned as desired in lp1396764), without causing further bloat to the object.
The challenge to this refactor would be that every part of the codebase that references the Org Unit Hours of Operation would need to be changed significantly to move over to this version of the object. Beyond the UI portions, there are references in the Perl, and significant sql edits would need to be made as well.
tags: | added: admin-pages circulation |
Would this design allow for there to be multiple entries for each day? Making the split hours function much easier? And support 3+ open chunks in a day?
Would this make it easier to mesh with the closed dates feature also?
I've often wished for there to be a set of DB functions to make the open/closed status of an org easier to access in custom scripts. I think this design change would make that easier to do.
Things like this, that would take into account open days and set closed holidays from the closed days editor. 102,'2022- 02-11': :timestamp) ; --bool, is org open on specified date or timesamp. (102, 7); --Return date equal to 7 open days from now for org unit. For hold shelf time for instance. Or for due dates for items.
OrgOpenNow(102); --bool is org open right now
OrgOpenToday(102); --bool is org open today at any time.
OrgOpenOn(
OrgNextOpen(102); --Next open timestamp for org
OrgNextClosed(102); --When does the org close next, useful for same day/in library use hourly checkouts being due at next closing time.
OrgNextOpenDays
It would be great to have any easy way to only run a cron job if a location is open. Or to be able to add open date and time logic to action_trigger processing.
Anyway, +1 for me