From 65f5afc47e9ed0d3006eeba963c6c7057479cdae Mon Sep 17 00:00:00 2001
From: Galen Charlton <gmc@equinoxinitiative.org>
Date: Thu, 13 Sep 2018 14:25:05 -0400
Subject: [PATCH] LP#1792429: calculate queue position in correct order

This patch ensures that the relative hold queue position
displayed in the webstaff Hold Shelf and Record -> View Holds
interfaces is calculated in the correct order, i.e., (cut-in-line aside)
with holds requested earlier having a lower queue position than
holds requested later.

To test
-------
[1] Set up a bib with a number of hold requests.
[2] Under Record -> Viwe Holds, note that the queue
    positions are reversed, with later holds having lower
    queue positions.
[3] Apply the patch and repeat step #2. This time, the queue
    positions should be correct.

Signed-off-by: Galen Charlton <gmc@equinoxinitiative.org>
Signed-off-by: Bill Erickson <berickxx@gmail.com>
---
 .../src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm    | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
index 238746ce31..3c69f3302c 100644
--- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
+++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Storage/Publisher/action.pm
@@ -2302,7 +2302,7 @@ SELECT  h.id, h.request_time, h.capture_time, h.fulfillment_time, h.checkin_time
 
         ROW_NUMBER() OVER (
             PARTITION BY r.bib_record
-            ORDER BY h.cut_in_line DESC NULLS LAST, h.request_time DESC
+            ORDER BY h.cut_in_line DESC NULLS LAST, h.request_time ASC
         ) AS relative_queue_position,
 
         EXTRACT(EPOCH FROM COALESCE(
-- 
2.11.0