From ef84757adf08f8e40c66e98387847cb8bff6335d Mon Sep 17 00:00:00 2001 From: mattf Date: Fri, 17 Jul 2015 17:34:30 +0000 Subject: [PATCH] Optimization for dialable lead count SQL git-svn-id: svn://192.168.202.10@2353 3d104415-ff17-0410-8863-d5cf3c621b8a --- agc_2-X/trunk/bin/AST_VDhopper.pl | 21 +++++++++++---------- agc_2-X/trunk/www/vicidial/admin.php | 22 +++++++++------------- 2 files changed, 20 insertions(+), 23 deletions(-) diff --git a/agc_2-X/trunk/bin/AST_VDhopper.pl b/agc_2-X/trunk/bin/AST_VDhopper.pl index 4c0ca154..aa6257c3 100644 --- a/agc_2-X/trunk/bin/AST_VDhopper.pl +++ b/agc_2-X/trunk/bin/AST_VDhopper.pl @@ -1885,7 +1885,14 @@ foreach(@campaign_id) } else { - $list_id_sql[$i] .= ",'$cur_list_id'"; + if (length($list_id_sql[$i]) < 3) + { + $list_id_sql[$i] = "(list_id IN('$cur_list_id'"; + } + else + { + $list_id_sql[$i] .= ",'$cur_list_id'"; + } } $act_rec_countLISTS++; } @@ -2287,15 +2294,8 @@ foreach(@campaign_id) #only add for use if the list is active if ( ($list_id_act eq "Y") || ($allow_inactive eq "Y") ) { - if ( ( ($act_rec_countLISTS == 0) && ($allow_inactive ne "Y") ) || ( ($rec_countLISTS == 0) && ($allow_inactive eq "Y") ) ) - { - $list_id_sql[$i] = "((list_id=\"$cur_list_id\" and gmt_offset_now IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; - } - else - { - $list_id_sql[$i] .= " or ((list_id=\"$cur_list_id\" and gmt_offset_now IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; - } - $del_list_id_sql[$i] .= "((list_id=\"$cur_list_id\" and gmt_offset_now NOT IN($list_default_gmt) $ct_statesSQL) $del_list_state_gmt_SQL) or"; + $LCTlist_id_sql[$i] .= " or ((list_id='$cur_list_id' and gmt_offset_now IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; + $del_list_id_sql[$i] .= "((list_id='$cur_list_id' and gmt_offset_now NOT IN($list_default_gmt) $ct_statesSQL) $del_list_state_gmt_SQL) or"; $act_rec_countLISTS++; } } @@ -2308,6 +2308,7 @@ foreach(@campaign_id) # Protect against campaigns with no list by making it an impossible list if (length($list_id_sql[$i]) < 1) {$list_id_sql[$i]="list_id='999876543210'";} else {$list_id_sql[$i] .= "))";} + if (length($LCTlist_id_sql[$i]) > 0) {$list_id_sql[$i] .= "$LCTlist_id_sql[$i]";} if ($DB) {print " campaign lists count ACTIVE:$act_rec_countLISTS | TOTAL:$rec_countLISTS \n";} if ($DBX) {print " LIST ID SQL $list_id_sql[$i]";} diff --git a/agc_2-X/trunk/www/vicidial/admin.php b/agc_2-X/trunk/www/vicidial/admin.php index 5f361c71..faca8287 100644 --- a/agc_2-X/trunk/www/vicidial/admin.php +++ b/agc_2-X/trunk/www/vicidial/admin.php @@ -3527,12 +3527,13 @@ else # 150706-0811 - Added user setting for lead_filter_id in no-hopper dialing # 150708-2246 - Added max_queue_ingroup_ DID settings options # 150710-1120 - Added options for alternate Dispo Call URLs +# 150717-1333 - Optimization for dialable lead count SQL # # make sure you have added a user to the vicidial_users MySQL table with at least user_level 9 to access this page the first time -$admin_version = '2.12-496a'; -$build = '150710-1120'; +$admin_version = '2.12-497a'; +$build = '150717-1333'; $STARTtime = date("U"); $SQLdate = date("Y-m-d H:i:s"); @@ -36120,26 +36121,19 @@ if (isset($camp_lists)) } $list_default_gmt = "$list_default_gmt'99'"; - if ($k == 0) - { - $list_id_sql = "((list_id=\"$cur_list_id\" and gmt_offset_now NOT IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; - } - else - { - $list_id_sql .= " or ((list_id=\"$cur_list_id\" and gmt_offset_now NOT IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; - } + $LCTlist_id_sql .= " or ((list_id='$cur_list_id' and gmt_offset_now NOT IN($list_default_gmt) $ct_statesSQL) $list_state_gmt_SQL)"; } ##### END local call time for list set different than campaign ##### else { - if ($k == 0) + if (strlen($list_id_sql) < 3) { - $list_id_sql = "(list_id=\"$cur_list_id\")"; + $list_id_sql = "(list_id IN('$cur_list_id'"; } else { - $list_id_sql .= " or (list_id=\"$cur_list_id\")"; + $list_id_sql .= ",'$cur_list_id'"; } } @@ -36148,6 +36142,8 @@ if (isset($camp_lists)) $camp_lists = preg_replace("/.$/i","",$camp_lists); if (strlen($camp_lists) < 4) {$camp_lists="''";} if (strlen($list_id_sql) < 4) {$list_id_sql="list_id=''";} + else {$list_id_sql .= '))';} + if (strlen($LCTlist_id_sql) > 1) {$list_id_sql .= "$LCTlist_id_sql";} $stmt="SELECT count(*) FROM vicidial_list where called_since_last_reset='N' and status IN($Dsql) and list_id IN($camp_lists) and ($list_id_sql) and ($all_gmtSQL) $CCLsql $DLTsql $fSQL $EXPsql";