diff --git a/bin/AST_DB_optimize.pl b/bin/AST_DB_optimize.pl index ecdee168..4436675c 100644 --- a/bin/AST_DB_optimize.pl +++ b/bin/AST_DB_optimize.pl @@ -14,6 +14,7 @@ # 60718-1645 - changed to use /etc/astguiclient.conf for configs # 71030-2020 - Added deletions of stats and inbound live agents # 71109-1725 - fixed vicidial_campaign_stats bug +# 71215-0410 - fixed UPDATE/DELETE results # # default path to astguiclient configuration file: @@ -251,58 +252,43 @@ $dbhA = DBI->connect("DBI:mysql:$VARDB_database:$VARDB_server:$VARDB_port", "$VA $stmtA = "UPDATE vicidial_campaign_stats SET dialable_leads='0', calls_today='0', answers_today='0', drops_today='0', drops_today_pct='0', drops_answers_today_pct='0', calls_hour='0', answers_hour='0', drops_hour='0', drops_hour_pct='0', calls_halfhour='0', answers_halfhour='0', drops_halfhour='0', drops_halfhour_pct='0', calls_fivemin='0', answers_fivemin='0', drops_fivemin='0', drops_fivemin_pct='0', calls_onemin='0', answers_onemin='0', drops_onemin='0', drops_onemin_pct='0', differential_onemin='0', agents_average_onemin='0', balance_trunk_fill='0', status_category_count_1='0', status_category_count_2='0', status_category_count_3='0', status_category_count_4='0';"; if($DB){print STDERR "\n|$stmtA|\n";} - if (!$T) { - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - @aryA = $sthA->fetchrow_array; - if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} - $sthA->finish(); - } + if (!$T) + { + $affected_rows = $dbhA->do($stmtA); + if(!$Q){print STDERR "\n|$affected_rows vicidial_campaign_stats records reset|\n";} + } $stmtA = "delete from vicidial_campaign_server_stats;"; if($DB){print STDERR "\n|$stmtA|\n";} - if (!$T) { - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - @aryA = $sthA->fetchrow_array; - if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} - $sthA->finish(); - } + if (!$T) + { + $affected_rows = $dbhA->do($stmtA); + if(!$Q){print STDERR "\n|$affected_rows vicidial_campaign_server_stats records deleted|\n";} + } $stmtA = "delete from vicidial_live_inbound_agents;"; if($DB){print STDERR "\n|$stmtA|\n";} - if (!$T) { - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - @aryA = $sthA->fetchrow_array; - if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} - $sthA->finish(); - } + if (!$T) + { + $affected_rows = $dbhA->do($stmtA); + if(!$Q){print STDERR "\n|$affected_rows vicidial_live_inbound_agents records deleted|\n";} + } $stmtA = "update vicidial_inbound_group_agents SET calls_today=0;;"; if($DB){print STDERR "\n|$stmtA|\n";} - if (!$T) { - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - @aryA = $sthA->fetchrow_array; - if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} - $sthA->finish(); - } + if (!$T) + { + $affected_rows = $dbhA->do($stmtA); + if(!$Q){print STDERR "\n|$affected_rows vicidial_inbound_group_agents call counts reset|\n";} + } $stmtA = "update vicidial_campaign_agents SET calls_today=0;;"; if($DB){print STDERR "\n|$stmtA|\n";} - if (!$T) { - $sthA = $dbhA->prepare($stmtA) or die "preparing: ",$dbhA->errstr; - $sthA->execute or die "executing: $stmtA ", $dbhA->errstr; - $sthArows=$sthA->rows; - @aryA = $sthA->fetchrow_array; - if (!$Q) {print "|",$aryA[0],"|",$aryA[1],"|",$aryA[2],"|",$aryA[3],"|","\n";} - $sthA->finish(); - } + if (!$T) + { + $affected_rows = $dbhA->do($stmtA); + if(!$Q){print STDERR "\n|$affected_rows vicidial_campaign_agents call counts reset|\n";} + } $dbhA->disconnect();