Skip to content

Commit

Permalink
Fix fake call and discrepancy from cdr and queue_log on duration of a…
Browse files Browse the repository at this point in the history
…nswered calls
  • Loading branch information
andrea-marchionni committed Jun 24, 2024
1 parent 840a222 commit db078f3
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions root/opt/nethvoice-report/scripts/queue-miner.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@

# Copy queue_log content into queue_log_history
$sqls = array();

# Delete RINGNOANSWER rows where duration is <= 1000 ms, they are fake calls caused by incorrect queues configuration
$sqls[] = "DELETE FROM queue_log WHERE event='RINGNOANSWER' and data1 in ('0','1000')";

$sqls[] = "INSERT IGNORE INTO queue_log_history (time,callid,queuename,agent,event,data,data1,data2,data3,data4,data5) SELECT time,callid,queuename,agent,event,data,data1,data2,data3,data4,data5 FROM queue_log WHERE UNIX_TIMESTAMP(time) < ?";

# Delete queue_log
Expand Down Expand Up @@ -206,9 +210,9 @@ function do_time_queries($start_ts,$end_ts) {
INNER JOIN asterisk.queues_config qc ON queuename=qc.extension
INNER JOIN (
SELECT dst_cnam,billsec,dstchannel, zid FROM (
SELECT dst_cnam,billsec,dstchannel, linkedid AS zid FROM tmp_cdr WHERE linkedid != uniqueid AND disposition ='ANSWERED' AND dstchannel NOT LIKE 'Local%' AND UNIX_TIMESTAMP(calldate) > $start_ts AND UNIX_TIMESTAMP(calldate) < $end_ts
UNION ALL
SELECT dst_cnam,billsec,dstchannel, uniqueid AS zid FROM tmp_cdr WHERE linkedid != uniqueid AND disposition ='ANSWERED' AND dstchannel NOT LIKE 'Local%' AND UNIX_TIMESTAMP(calldate) > $start_ts AND UNIX_TIMESTAMP(calldate) < $end_ts
UNION ALL
SELECT dst_cnam,billsec,dstchannel, linkedid AS zid FROM tmp_cdr WHERE linkedid != uniqueid AND disposition ='ANSWERED' AND dstchannel NOT LIKE 'Local%' AND UNIX_TIMESTAMP(calldate) > $start_ts AND UNIX_TIMESTAMP(calldate) < $end_ts order by calldate
) temp GROUP BY zid
) c ON zid = callid
LEFT JOIN agent_extensions ON SUBSTRING(REPLACE(dstchannel,'PJSIP/',''),1,POSITION('-' IN REPLACE(dstchannel,'PJSIP/',''))-1) = agent_extensions.extension
Expand Down

0 comments on commit db078f3

Please sign in to comment.