From 84f6d3012240790df3037e7cac1fd63149d30aa3 Mon Sep 17 00:00:00 2001 From: Vsevolod Stakhov Date: Mon, 16 Jul 2018 13:42:02 +0100 Subject: [PATCH] [Minor] Fix end/start times when processing multiple log files --- utils/rspamd_stats.pl | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/utils/rspamd_stats.pl b/utils/rspamd_stats.pl index b997ff525..ac7b1349f 100755 --- a/utils/rspamd_stats.pl +++ b/utils/rspamd_stats.pl @@ -508,12 +508,22 @@ sub ProcessLog { next if ( $skip != 0 ); - $timeStamp{'end'} = $ts; - $timeStamp{'start'} //= $timeStamp{'end'}; - $scanTime{'min'} = $scan_time - if ( !exists $scanTime{'min'} || $scanTime{'min'} > $scan_time ); - $scanTime{'max'} = $scan_time - if ( $scanTime{'max'} < $scan_time ); + if (defined($timeStamp{'end'})) { + $timeStamp{'end'} = $ts if ( $ts gt $timeStamp{'end'} ); + } + else { + $timeStamp{'end'} = $ts; + } + + if (defined($timeStamp{'start'})) { + $timeStamp{'start'} = $ts if ( $ts lt $timeStamp{'start'} ); + } + else { + $timeStamp{'start'} = $ts; + } + + $scanTime{'min'} = $scan_time if ( !exists $scanTime{'min'} || $scanTime{'min'} > $scan_time ); + $scanTime{'max'} = $scan_time if ( $scanTime{'max'} < $scan_time ); $scanTime{'total'} += $scan_time; $action{$act}++; -- 2.39.5