Return to using the custom hold queue position calculation code.
This merely moves the logic from the DB back into the Perl code. The
query logic is unchanged.
Signed-off-by: Bill Erickson <berickxx@gmail.com>
--- /dev/null
+-- Deploy kcls-evergreen:revert-custom-qstats to pg
+-- requires: backstage-exports-continued
+
+BEGIN;
+
+DROP FUNCTION IF EXISTS action.get_hold_queue_status_by_id(INTEGER);
+
+COMMIT;
--- /dev/null
+-- Revert kcls-evergreen:revert-custom-qstats from pg
+
+BEGIN;
+
+CREATE OR REPLACE FUNCTION get_hold_queue_status_by_id(integer)
+ RETURNS TABLE(id integer, cut_in_line boolean, request_time timestamp with time zone)
+ LANGUAGE sql STABLE
+ AS $_$
+WITH holds(holdid) AS
+( SELECT acm.hold FROM action.hold_copy_map acm
+ JOIN action.hold_copy_map acm2 USING(target_copy)
+ WHERE acm2.hold=$1)
+ SELECT id, cut_in_line, request_time FROM action.hold_request
+ WHERE id IN (SELECT holdid FROM holds)
+ ORDER BY coalesce(cut_in_line, false ) DESC, request_time;
+$_$;
+
+COMMIT;
+
2.7-to-2.9-upgrade [backstage-exports-continued] 2016-12-09T20:27:17Z Bill Erickson <berickxx@gmail.com> # 2.7 to 2.9 Upgrade
2.7-to-2.9-upgrade-part-2 [2.7-to-2.9-upgrade] 2016-12-12T15:19:07Z Bill Erickson <berickxx@gmail.com> # 2.7 to 2.9 Upgrade Secondary Updates
pg-9.6-prep [2.7-to-2.9-upgrade-part-2] 2017-03-20T15:59:10Z Bill Erickson,,, <berick@cylinders> # Prep for PG 9.6
+revert-custom-qstats [backstage-exports-continued] 2017-02-06T22:09:42Z Bill Erickson <berickxx@gmail.com> # Remove custom hold queue position func
--- /dev/null
+-- Verify kcls-evergreen:revert-custom-qstats on pg
+
+BEGIN;
+
+-- XXX Add verifications here.
+
+ROLLBACK;
# fetch cut_in_line and request_time since they're in the order_by
# and we're asking for distinct values
- from => [ "action.get_hold_queue_status_by_id", $hold->id ]
+ select => {ahr => ['id', 'cut_in_line', 'request_time']},
+ from => 'ahr',
+ where => {
+ id => { in => {
+ select => { ahcm => ['hold'] },
+ from => {
+ 'ahcm' => {
+ 'ahcm2' => {
+ 'class' => 'ahcm',
+ 'field' => 'target_copy',
+ 'fkey' => 'target_copy'
+ }
+ }
+ },
+ where => { '+ahcm2' => { hold => $hold->id } },
+ distinct => 1
+ }}
+ },
+ order_by => [
+ {
+ "class" => "ahr",
+ "field" => "cut_in_line",
+ "transform" => "coalesce",
+ "params" => [ 0 ],
+ "direction" => "desc"
+ },
+ { "class" => "ahr", "field" => "request_time" }
+ ],
+ distinct => 1
});
if (!@$q_holds) { # none? maybe we don't have a map ...