}
+ my $pr_delay = FS::Record->scalar_sql('
+ SELECT AVG(end_date-start_date)
+ FROM queue_stat
+ GROUP BY statnum
+ ORDER BY statnum DESC
+ LIMIT 100
+ ');
+ if ( $pr_delay ) {
+ my $h = int($delay/3600);
+ my $m = int( ($delay%3600) / 60 );
+ my $s = $delay%60;
+
+ $pr_delay = ( $h ? $h. 'h' : '' ).
+ ( $h||$m ? $m. 'm' : '').
+ $s. 's';
+
+ }
+
+ my $dayago = time2str('%Y-%m-%d %X', time - 86400);
+ my $cdrs = FS::Record->scalar_sql(qq{
+ SELECT COUNT(*) FROM cdr
+ WHERE ( freesidestatus IS NULL OR freesidestatus = '' )
+ AND calldate > '$dayago'
+ });
+
$status{'CDR Processing'} = [
{ 'title' => 'Current processing delay',
'value' => $delay,
},
+ { 'title' => 'Average billing time',
+ 'value' => $pr_delay,
+ },
+ { 'title' => 'Unprocessed CDRs (last 24 hours)',
+ 'value' => $cdrs,
+ },
];
}