[open-ils-commits] r15418 - branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher (miker)
svn at svn.open-ils.org
svn at svn.open-ils.org
Mon Feb 1 12:25:59 EST 2010
Author: miker
Date: 2010-02-01 12:25:56 -0500 (Mon, 01 Feb 2010)
New Revision: 15418
Modified:
branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
Log:
Backporting r15146: Patch from Doug Kyle to address transit-related deficiency in the reshelving-complete query
Modified: branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm
===================================================================
--- branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm 2010-02-01 17:25:34 UTC (rev 15417)
+++ branches/rel_1_6_0/Open-ILS/src/perlmods/OpenILS/Application/Storage/Publisher/action.pm 2010-02-01 17:25:56 UTC (rev 15418)
@@ -131,35 +131,43 @@
my $setting = actor::org_unit_setting->table;
my $circ = action::circulation->table;
my $cp = asset::copy->table;
+ my $atc = action::transit_copy->table;
my $sql = <<" SQL";
UPDATE $cp
SET status = 0
WHERE id IN (
- SELECT id
- FROM (SELECT cp.id, MAX(circ.checkin_time)
- FROM $cp cp
- JOIN $circ circ ON (circ.target_copy = cp.id)
- LEFT JOIN $setting setting
- ON (cp.circ_lib = setting.org_unit AND setting.name = 'circ.reshelving_complete.interval')
- WHERE circ.checkin_time IS NOT NULL
- AND cp.status = 7
- GROUP BY 1
- HAVING MAX(circ.checkin_time) < NOW() - CAST( COALESCE( BTRIM( FIRST(setting.value),'"' ), ? ) AS INTERVAL)
- ) AS foo
- UNION ALL
- SELECT cp.id
- FROM $cp cp
- LEFT JOIN $setting setting
- ON (cp.circ_lib = setting.org_unit AND setting.name = 'circ.reshelving_complete.interval')
- LEFT JOIN $circ circ ON (circ.target_copy = cp.id)
- WHERE cp.status = 7 AND circ.id IS NULL
- AND cp.create_date < NOW() - CAST( COALESCE( BTRIM( setting.value,'"' ), ? ) AS INTERVAL)
- )
- SQL
-
+ SELECT id
+ FROM (SELECT cp.id, MAX(circ.checkin_time), MAX(trans.dest_recv_time)
+ FROM $cp cp
+ JOIN $circ circ ON (circ.target_copy = cp.id)
+ LEFT JOIN $atc trans ON (trans.target_copy = cp.id)
+ LEFT JOIN $setting setting
+ ON (cp.circ_lib = setting.org_unit AND setting.name = 'circ.reshelving_complete.interval')
+ WHERE circ.checkin_time IS NOT NULL
+ AND cp.status = 7
+ GROUP BY 1
+ HAVING (
+ ( ( MAX(circ.checkin_time) > MAX(trans.dest_recv_time) or MAX(trans.dest_recv_time) IS NULL )
+ AND MAX(circ.checkin_time) < NOW() - CAST( COALESCE( BTRIM( FIRST(setting.value),'"' ), ? ) AS INTERVAL) )
+ OR
+ ( MAX(trans.dest_recv_time) > MAX(circ.checkin_time)
+ AND MAX(trans.dest_recv_time) < NOW() - CAST( COALESCE( BTRIM( FIRST(setting.value),'"' ), ? ) AS INTERVAL) )
+ )
+ ) AS foo
+ UNION ALL
+ SELECT cp.id
+ FROM $cp cp
+ LEFT JOIN $setting setting
+ ON (cp.circ_lib = setting.org_unit AND setting.name = 'circ.reshelving_complete.interval')
+ LEFT JOIN $circ circ ON (circ.target_copy = cp.id)
+ WHERE cp.status = 7
+ AND circ.id IS NULL
+ AND cp.create_date < NOW() - CAST( COALESCE( BTRIM( setting.value,'"' ), ? ) AS INTERVAL)
+ )
+ SQL
my $sth = action::circulation->db_Main->prepare_cached($sql);
- $sth->execute($window, $window);
+ $sth->execute($window, $window, $window);
return $sth->rows;
More information about the open-ils-commits
mailing list