From b145369c6b4e08397e0e3acbab90061f563ee5de Mon Sep 17 00:00:00 2001 From: miker Date: Wed, 28 Oct 2009 17:41:55 +0000 Subject: [PATCH] add support for sorting the pull list by asset.copy_location_order when set git-svn-id: svn://svn.open-ils.org/ILS/trunk@14652 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm | 8 ++++++++ .../src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm | 6 ++++++ .../src/perlmods/OpenILS/Application/Storage/Publisher/action.pm | 4 +++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm index cd57a8d93b..7a4dfbe5f0 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/CDBI/asset.pm @@ -13,6 +13,14 @@ __PACKAGE__->columns( Primary => qw/id/ ); __PACKAGE__->columns( Essential => qw/name owning_lib holdable hold_verify opac_visible circulate/ ); #------------------------------------------------------------------------------- +package asset::copy_location_order; +use base qw/asset/; + +__PACKAGE__->table( 'asset_copy_location_order' ); +__PACKAGE__->columns( Primary => qw/id/ ); +__PACKAGE__->columns( Essential => qw/location org position/ ); + +#------------------------------------------------------------------------------- package asset::call_number; use base qw/asset/; diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm index 3bb16d944a..2da5d7c94e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Driver/Pg/dbi.pm @@ -292,6 +292,12 @@ asset::call_number->sequence( 'asset.call_number_id_seq' ); #--------------------------------------------------------------------- + package asset::copy_location_order; + + asset::copy_location_order->table( 'asset.copy_location_order' ); + asset::copy_location_order->sequence( 'asset.copy_location_order_id_seq' ); + + #--------------------------------------------------------------------- package asset::copy_location; asset::copy_location->table( 'asset.copy_location' ); diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm index 7b431d4108..5f405cba26 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm @@ -408,6 +408,7 @@ sub hold_pull_list { return undef unless ($ou); my $h_table = action::hold_request->table; my $a_table = asset::copy->table; + my $ord_table = asset::copy_location_order->table; my $idlist = 1 if ($self->api_name =~/id_list/o); @@ -418,12 +419,13 @@ sub hold_pull_list { SELECT h.* FROM $h_table h JOIN $a_table a ON (h.current_copy = a.id) + LEFT JOIN $ord_table ord (a.location = ord.location AND a.circ_lib = ord.org) WHERE a.circ_lib = ? AND h.capture_time IS NULL AND h.cancel_time IS NULL AND (h.expire_time IS NULL OR h.expire_time > NOW()) $status_filter - ORDER BY h.request_time ASC + ORDER BY CASE WHEN ord.position IS NOT NULL THEN ord.position ELSE 999 END, h.request_time LIMIT $limit OFFSET $offset SQL -- 2.11.0