From cd1b14359c6953fa73e6700546833fcb8d56114f Mon Sep 17 00:00:00 2001 From: miker Date: Mon, 19 Jul 2010 15:06:59 +0000 Subject: [PATCH] use LEFT JOIN to allow a single query to count copies per circ mod git-svn-id: svn://svn.open-ils.org/ILS/trunk@16979 dcc99617-32d9-48b4-a31d-7c20da2025e4 --- .../src/perlmods/OpenILS/Application/Circ/Holds.pm | 32 ++++++++-------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm index 56062fee9..f6361eabf 100644 --- a/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm +++ b/Open-ILS/src/perlmods/OpenILS/Application/Circ/Holds.pm @@ -1085,29 +1085,21 @@ sub retrieve_hold_queue_status_impl { my $hold_data = $e->json_query({ select => { - ccm => [ - {column => 'code', transform => 'count', aggregate => 1, alias => 'count'}, - {column =>'avg_wait_time'} - ] + acp => [ {column => 'id', transform => 'count', aggregate => 1, alias => 'count'} ], + ccm => [ {column =>'avg_wait_time'} ] + }, + from => { + ahcm => { + acp => { + join => { + ccm => {type => 'left'} + } + } + } }, - from => {ahcm => {acp => {join => 'ccm'}}}, - where => {'+ahcm' => {hold => $hold->id}} + where => {'+ahcm' => {hold => $hold->id} } }); - - # take into account copies that have no circ modifier - my $no_circ_mods = $e->json_query({ - select => { - acp => [ - {column => 'id', transform => 'count', aggregate => 1, alias => 'count'} - ] - }, - from => {ahcm => 'acp'}, - where => {'+ahcm' => {hold => $hold->id}, '+acp' => {circ_modifier => undef}} - })->[0]; - - push(@$hold_data, {count => $no_circ_mods->{count}}) if $no_circ_mods; - my $user_org = $e->json_query({select => {au => ['home_ou']}, from => 'au', where => {id => $hold->usr}})->[0]->{home_ou}; my $default_wait = $U->ou_ancestor_setting_value($user_org, OILS_SETTING_HOLD_ESIMATE_WAIT_INTERVAL); -- 2.11.0