diff --git a/agc_2-X/trunk/bin/AST_cleanup_agent_log.pl b/agc_2-X/trunk/bin/AST_cleanup_agent_log.pl index ff5532ba..5a7fa31f 100644 --- a/agc_2-X/trunk/bin/AST_cleanup_agent_log.pl +++ b/agc_2-X/trunk/bin/AST_cleanup_agent_log.pl @@ -10,7 +10,7 @@ # # This program only needs to be run by one server # -# Copyright (C) 2020 Matt Florell LICENSE: AGPLv2 +# Copyright (C) 2021 Matt Florell LICENSE: AGPLv2 # # CHANGES # 60711-0945 - Changed to DBI by Marin Blu @@ -45,6 +45,7 @@ # 200422-1621 - Added optional check for duplicate vicidial_agent_log entries # 200606-1802 - Added optional queue_log cleanup for multiple PAUSEREASON records in the same PAUSE session # 201106-2146 - Added EXITEMPTY verb for queue_log cleanup section +# 210523-2321 - Added optional check for qa_data duplicates, -qm-qa-duplicate-check # # constants @@ -79,12 +80,13 @@ if (length($ARGV[0])>1) print " [-only-check-agent-login-lags] = will only fix queue_log missing PAUSEREASON records\n"; print " [-only-qm-live-call-check] = will only check the queue_log calls that report as live, in ViciDial\n"; print " [-qm-pausereason-check] = will check/fix the queue_log for multiple PAUSEREASON entries in same pause session\n"; + print " [-qm-qa-duplicate-check] = will check/fix the qa_data table for duplicates\n"; print " [-only-fix-old-lagged] = will go through old lagged entries and add a new entry after\n"; print " [-only-dedupe-vicidial-log] = will look for duplicate vicidial_log and extended entries\n"; print " [-only-check-vicidial-log-agent] = will check for missing agent log entries\n"; print " [-only-hold-cleanup] = will look for hold entries and correct agent log wait/talk times\n"; print " [-run-check] = concurrency check, die if another instance is running\n"; - print " [-q] = quiet, no output\n"; + print " [-quiet] = quiet, no output\n"; print " [-test] = test\n"; print " [-debug] = verbose debug messages\n"; print " [-debugX] = Extra-verbose debug messages\n\n"; @@ -92,7 +94,7 @@ if (length($ARGV[0])>1) } else { - if ($args =~ /-q/i) + if ($args =~ /-quiet/i) { $Q=1; # quiet } @@ -132,7 +134,12 @@ if (length($ARGV[0])>1) { $qm_pausereason_check=1; if ($Q < 1) {print "\n----- QM PAUSEREASON CHECK -----\n\n";} - } + } + if ($args =~ /-qm-qa-duplicate-check/i) + { + $qm_qa_duplicate_check=1; + if ($Q < 1) {print "\n----- QM QA DUPLICATE CHECK -----\n\n";} + } if ($args =~ /-only-dedupe-vicidial-log/i) { $vl_dup_check=1; @@ -977,6 +984,55 @@ if ($enable_queuemetrics_logging > 0) if ($DB) {print "PAUSEREASON cleanup done, records deleted: $PRdeleted ($PRsecondchoice) \n";} } + if ($qm_qa_duplicate_check > 0) + { + $QAdeleted=0; + ############################################################## + ##### grab top 1000 qa_data records ordered by duplicates first + $stmtB = "SELECT count(*) as tally,call_id,sys_dt_creazione,sys_user_creazione FROM qa_data group by call_id,sys_dt_creazione,sys_dt_creazione order by tally desc limit 1000;"; + $sthB = $dbhB->prepare($stmtB) or die "preparing: ",$dbhB->errstr; + $sthB->execute or die "executing: $stmtB ", $dbhB->errstr; + $P_qa_records=$sthB->rows; + if ($DB) {print "TOTAL QA duplicate check Records: $P_qa_records|$stmtB|\n";} + $h=0; $qa_dup_ct=0; + while ($P_qa_records > $h) + { + @aryB = $sthB->fetchrow_array; + if ($aryB[0] > 1) + { + $call_id[$qa_dup_ct] = $aryB[1]; + $qa_date[$qa_dup_ct] = $aryB[2]; + $agent[$qa_dup_ct] = $aryB[3]; + $qa_dup_ct++; + } + $h++; + } + $sthB->finish(); + + $h=0; + while ($qa_dup_ct > $h) + { + ##### find the most recent qa_data duplicate record and delete it + $stmtB = "DELETE FROM qa_data where call_id='$call_id[$h]' and sys_dt_creazione='$qa_date[$h]' and sys_user_creazione='$agent[$h]' order by qadata_id desc limit 1;"; + + if ($TEST < 1) + {$Baffected_rows = $dbhB->do($stmtB);} + if ($DB) {print " extra qa_data record deleted: $Baffected_rows|$stmtB|\n";} + $QAdeleted++; + + $event_string = "extra qa_data record deleted: $Baffected_rows|$h|$call_id[$h]|$qa_date[$h]|$agent[$h]|"; + &event_logger; + + $h++; + } + + @call_id=@MT; + @qa_date=@MT; + @agent=@MT; + + if ($DB) {print "QA DUPLICATE check done, records deleted: $QAdeleted \n";} + } + if ($DB) {print " - Checking queue_log in-queue calls in ViciDial\n";} ############################################################## diff --git a/agc_2-X/trunk/docs/QUEUEMETRICS.txt b/agc_2-X/trunk/docs/QUEUEMETRICS.txt index 2b67bb1e..b13843bf 100644 --- a/agc_2-X/trunk/docs/QUEUEMETRICS.txt +++ b/agc_2-X/trunk/docs/QUEUEMETRICS.txt @@ -1,4 +1,4 @@ -VICIDIAL and QueueMetrics UPDATED: 2020-05-18 +VICIDIAL and QueueMetrics UPDATED: 2020-05-24 queue_log logging was added to VICIDIAL outbound auto calling as an option in the 2.0.3 release, and for inbound in the 2.0.4 release. @@ -23,6 +23,8 @@ As of 2009-11-23, DID and IVR logging through QueueMetrics queue_log is now part As of 2010-03-09, queuemetrics_loginout system settings option was added to allow for slightly different logging of logins and logouts. STANDARD will use standard AGENTLOGIN AGENTLOGOFF, CALLBACK will use AGENTCALLBACKLOGIN and AGENTCALLBACKLOGOFF that QM will parse differently. +As of 2021-05-24, We added a "-qm-qa-duplicate-check" flag to the AST_cleanup_agent_log.pl script to check for and remove qa_data duplicate entries + NOTE: having a large number of calls in queue can lead to significant load issues on the QM database server