Skip to content

Commit 912173f

Browse files
spaceisntsyntaxmmorgannoble
authored andcommitted
LP#1954937: Provide both global and relative hold queue position
Generate the full, global (approximate) hold queue position for open (not yet canceled or fulfilled) holds based on the rhrr table. Then, provide just the in-result order among the peer-bib holds. This allows users to choose which of the two is more appropriate for each use case in their environment. This uses a strategically place correlated LEFT JOIN LATERAL in the FROM clause of the main query, rather than a CTE, in order to avoid materialization of the full peer-hold map, and instead only gathering the positional information for holds that are involved in the actual result set. The label for the existing relative_queue_position field is now "Relative Queue Position", and the label for the new global_queue_postion field is "Global Queue Postion". Release-note: Provide both global and result-set-relative hold queue position information, allowing staff to choose which is best for their purposes in each hold-listing interface. Signed-off-by: Mike Rylander <[email protected]> Signed-off-by: blake <[email protected]> Signed-off-by: Michele Morgan <[email protected]>
1 parent 3178291 commit 912173f

File tree

7 files changed

+22
-6
lines changed

7 files changed

+22
-6
lines changed

Open-ILS/src/eg2/src/app/staff/share/holds/grid.component.html

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,8 +286,10 @@ <h4 *ngIf="!hideHoldsCount" i18n>Holds Count: {{holdsCount}}</h4>
286286
<eg-grid-column i18n-label label="Hold Status" [cellTemplate]="statusTemplate" name="status_string"
287287
[sortable]="false" [multiSortable]="false">
288288
</eg-grid-column>
289-
<eg-grid-column i18n-label label="Queue Position"
289+
<eg-grid-column i18n-label label="Relative Queue Position"
290290
path='relative_queue_position' [hidden]="true" datatype="int"></eg-grid-column>
291+
<eg-grid-column i18n-label label="Global Queue Position"
292+
path='global_queue_position' [hidden]="true" datatype="int"></eg-grid-column>
291293
<eg-grid-column path='usr_id' i18n-label label="User ID" [hidden]="true"></eg-grid-column>
292294
<eg-grid-column path='usr_usrname' i18n-label label="Username" [hidden]="true"></eg-grid-column>
293295

Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2364,10 +2364,12 @@ SELECT h.id, h.request_time, h.capture_time, h.fulfillment_time, h.checkin_time
23642364
23652365
COALESCE(acplo.position, acpl_ordered.fallback_position) AS copy_location_order_position,
23662366
2367+
pos.global_queue_position, -- position among same-bib holds globally
2368+
23672369
ROW_NUMBER() OVER (
23682370
PARTITION BY r.bib_record
2369-
ORDER BY h.cut_in_line DESC NULLS LAST, h.request_time ASC
2370-
) AS relative_queue_position,
2371+
ORDER BY pos.global_queue_position
2372+
) AS relative_queue_position, -- position among same-bib holds that are actually in the result set
23712373
23722374
EXTRACT(EPOCH FROM COALESCE(
23732375
NULLIF(BTRIM(default_estimated_wait_interval.value,'"'),''),
@@ -2422,6 +2424,13 @@ SELECT h.id, h.request_time, h.capture_time, h.fulfillment_time, h.checkin_time
24222424
LEFT JOIN actor.org_unit ol ON (cn.owning_lib = ol.id)
24232425
LEFT JOIN LATERAL (SELECT * FROM action.hold_transit_copy WHERE h.id = hold ORDER BY id DESC LIMIT 1) tr ON TRUE
24242426
LEFT JOIN actor.org_unit tl ON (tr.source = tl.id)
2427+
LEFT JOIN LATERAL ( -- correlated subquery finding the aprox ordering of open peer holds per bib, but ONLY for holds we'll eventually return!
2428+
SELECT sr.id,
2429+
ROW_NUMBER() OVER (ORDER BY sh.cut_in_line DESC NULLS LAST, sh.request_time) AS global_queue_position
2430+
FROM action.hold_request sh
2431+
JOIN reporter.hold_request_record sr ON (sh.id = sr.id AND sh.cancel_time IS NULL AND sh.fulfillment_time IS NULL)
2432+
WHERE sr.bib_record = r.bib_record
2433+
) pos ON (pos.id=h.id)
24252434
LEFT JOIN LATERAL (SELECT COUNT(*) FROM action.hold_request_note WHERE h.id = hold AND (pub = TRUE OR staff = $is_staff_request)) notes ON TRUE
24262435
LEFT JOIN LATERAL (SELECT COUNT(*), MAX(notify_time) FROM action.hold_notification WHERE h.id = hold) n ON TRUE
24272436
LEFT JOIN LATERAL (SELECT FIRST(value) AS value FROM metabib.display_entry WHERE source = r.bib_record AND field = t_field.field) t ON TRUE

Open-ILS/src/templates/staff/cat/catalog/t_holds.tt2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,8 @@
8484
<eg-grid-field label="[% l('Potential Items') %]" path='hold.potentials' name='potentials'></eg-grid-field>
8585
<eg-grid-field label="[% l('Status') %]" path='status_string' name='hold_status'></eg-grid-field>
8686

87-
<eg-grid-field label="[% l('Queue Position') %]" path='hold.relative_queue_position' name='relative_queue_position' hidden></eg-grid-field>
87+
<eg-grid-field label="[% l('Relative Queue Position') %]" path='hold.relative_queue_position' name='relative_queue_position' hidden></eg-grid-field>
88+
<eg-grid-field label="[% l('Global Queue Position') %]" path='hold.global_queue_position' name='global_queue_position' hidden></eg-grid-field>
8889

8990
<eg-grid-field path='hold.usr_id' label="[% l('User ID') %]" name='usr_id' hidden></eg-grid-field>
9091
<eg-grid-field path='hold.usr_usrname' label="[% l('Username') %]" name='usr_usrname' hidden></eg-grid-field>

Open-ILS/src/templates/staff/circ/holds/t_shelf_list.tt2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
<eg-grid-field label="[% l('Potential Items') %]" path='hold.potentials'></eg-grid-field>
7474
<eg-grid-field label="[% l('Status') %]" path='status_string'></eg-grid-field>
7575

76-
<eg-grid-field label="[% l('Queue Position') %]" path='hold.relative_queue_position' hidden></eg-grid-field>
76+
<eg-grid-field label="[% l('Relative Queue Position') %]" path='hold.relative_queue_position' hidden></eg-grid-field>
77+
<eg-grid-field label="[% l('Global Queue Position') %]" path='hold.global_queue_position' hidden></eg-grid-field>
7778
<eg-grid-field label="[% l('Item Status') %]" path="hold.cs_name" hidden></eg-grid-field>
7879

7980
<eg-grid-field label="[% l('Fulfillment Date/Time') %]" path='hold.fulfillment_time' datatype="timestamp" hidden></eg-grid-field>

Open-ILS/src/templates/staff/circ/patron/t_holds_list.tt2

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,8 @@
7373
<eg-grid-field label="[% l('Potential Items') %]" path='hold.potentials'></eg-grid-field>
7474
<eg-grid-field label="[% l('Status') %]" path='status_string'></eg-grid-field>
7575

76-
<eg-grid-field label="[% l('Queue Position') %]" path='hold.relative_queue_position' hidden></eg-grid-field>
76+
<eg-grid-field label="[% l('Relative Queue Position') %]" path='hold.relative_queue_position' hidden></eg-grid-field>
77+
<eg-grid-field label="[% l('Global Queue Position') %]" path='hold.global_queue_position' hidden></eg-grid-field>
7778
<eg-grid-field label="[% l('Item Status') %]" path="hold.cs_name" hidden></eg-grid-field>
7879

7980
<eg-grid-field label="[% l('Fulfillment Date/Time') %]" path='hold.fulfillment_time' datatype="timestamp" hidden></eg-grid-field>

Open-ILS/web/js/ui/default/staff/circ/holds/app.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ function($scope , $q , $routeParams , $window , $location , egCore , egHolds , e
105105
// A list of fields we can't sort on the server side. That's ok, because
106106
// the grid is marked clientsort, so it always re-sorts in the browser.
107107
var cannot_sort = [
108+
'global_queue_position',
108109
'relative_queue_position',
109110
'default_estimated_wait',
110111
'min_estimated_wait',

Open-ILS/web/js/ui/default/staff/circ/patron/holds.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ function($scope, $q, $routeParams, egCore, egUser, patronSvc,
152152
// A list of fields we can't sort on the server side. That's ok, because
153153
// the grid is marked clientsort, so it always re-sorts in the browser.
154154
var cannot_sort = [
155+
'global_queue_position',
155156
'relative_queue_position',
156157
'default_estimated_wait',
157158
'min_estimated_wait',

0 commit comments

Comments
 (0)