From 7e80f821218f31c3b7872d8b3842904d1d83e884 Mon Sep 17 00:00:00 2001 From: phasefx Date: Mon, 26 Apr 2010 16:21:45 +0000 Subject: [PATCH] Don't rely on the sequence like this, using xact_start to find preceding circ renewal chain git-svn-id: svn://svn.open-ils.org/ILS/trunk@16305 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- Open-ILS/src/perlmods/OpenILS/Application/Circ.pm | 26 +++++++++-------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm index 3f4901a3a..bd259818e 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ.pm @@ -1537,17 +1537,14 @@ sub retrieve_prev_circ_chain { my $target_copy = $$first_circ{'target_copy'}; my $usr = $$first_circ{'usr'}; my $last_circ_from_prev_chain = $e->json_query({ - 'select' => { - 'circ' => [{ - 'column' => 'id', - 'transform' => 'max' - }] - }, + 'select' => { 'circ' => ['id'] }, 'from' => 'circ', 'where' => { target_copy => $target_copy, - id => { '<' => $$first_circ{'id'} } - } + xact_start => { '<' => $$first_circ{'xact_start'} } + }, + 'order_by' => [{ 'class'=>'circ', 'field'=>'xact_start', 'direction'=>'desc' }], + 'limit' => 1 })->[0]; return undef unless $last_circ_from_prev_chain; return undef unless $$last_circ_from_prev_chain{'id'}; @@ -1562,17 +1559,14 @@ sub retrieve_prev_circ_chain { my $first_circ = $e->json_query({from => ['action.circ_chain', $circ_id]})->[0]; my $target_copy = $$first_circ{'target_copy'}; my $last_circ_from_prev_chain = $e->json_query({ - 'select' => { - 'circ' => [{ - 'column' => 'id', - 'transform' => 'max' - }] - }, + 'select' => { 'circ' => ['id'] }, 'from' => 'circ', 'where' => { target_copy => $target_copy, - id => { '<' => $$first_circ{'id'} } - } + xact_start => { '<' => $$first_circ{'xact_start'} } + }, + 'order_by' => [{ 'class'=>'circ', 'field'=>'xact_start', 'direction'=>'desc' }], + 'limit' => 1 })->[0]; return undef unless $last_circ_from_prev_chain; return undef unless $$last_circ_from_prev_chain{'id'}; -- 2.11.0