From: Darold Gilles Date: Mon, 28 Apr 2014 19:35:29 +0000 (+0200) Subject: Fix double information in histogram data when period is the hour. X-Git-Tag: v5.1~11 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=8e65db0b470f643324755413a3577ad3db7e496f;p=pgbadger Fix double information in histogram data when period is the hour. --- diff --git a/pgbadger b/pgbadger index d5274e2..ad3c6c3 100644 --- a/pgbadger +++ b/pgbadger @@ -6521,12 +6521,14 @@ sub print_time_consuming $hourly_count{"$h:$rd"} += $normalyzed_info{$k}{chronos}{$d}{$h}{min}{$m}; $hourly_duration{"$h:$rd"} += ($normalyzed_info{$k}{chronos}{$d}{$h}{min_duration}{$m} || 0); } - foreach my $rd (@histo_avgs) { - next if (!exists $hourly_count{"$h:$rd"}); - $details .= "$zday$h:$rd" . - &comma_numbers($hourly_count{"$h:$rd"}) . "" . - &convert_time($hourly_duration{"$h:$rd"}) . "" . - &convert_time($hourly_duration{"$h:$rd"}/($hourly_count{"$h:$rd"}||1)) . ""; + if ($#histo_avgs > 0) { + foreach my $rd (@histo_avgs) { + next if (!exists $hourly_count{"$h:$rd"}); + $details .= "$zday$h:$rd" . + &comma_numbers($hourly_count{"$h:$rd"}) . "" . + &convert_time($hourly_duration{"$h:$rd"}) . "" . + &convert_time($hourly_duration{"$h:$rd"}/($hourly_count{"$h:$rd"}||1)) . ""; + } } } } @@ -6679,12 +6681,14 @@ sub print_most_frequent $hourly_count{"$h:$rd"} += $normalyzed_info{$k}{chronos}{$d}{$h}{min}{$m}; $hourly_duration{"$h:$rd"} += ($normalyzed_info{$k}{chronos}{$d}{$h}{min_duration}{$m} || 0); } - foreach my $rd (@histo_avgs) { - next if (!exists $hourly_count{"$h:$rd"}); - $details .= "$zday$h:$rd" . - &comma_numbers($hourly_count{"$h:$rd"}) . "" . - &convert_time($hourly_duration{"$h:$rd"}) . "" . - &convert_time($hourly_duration{"$h:$rd"}/($hourly_count{"$h:$rd"}||1)) . ""; + if ($#histo_avgs > 0) { + foreach my $rd (@histo_avgs) { + next if (!exists $hourly_count{"$h:$rd"}); + $details .= "$zday$h:$rd" . + &comma_numbers($hourly_count{"$h:$rd"}) . "" . + &convert_time($hourly_duration{"$h:$rd"}) . "" . + &convert_time($hourly_duration{"$h:$rd"}/($hourly_count{"$h:$rd"}||1)) . ""; + } } } } @@ -6838,12 +6842,14 @@ sub print_slowest_queries $hourly_count{"$h:$rd"} += $normalyzed_info{$k}{chronos}{$d}{$h}{min}{$m}; $hourly_duration{"$h:$rd"} += ($normalyzed_info{$k}{chronos}{$d}{$h}{min_duration}{$m} || 0); } - foreach my $rd (@histo_avgs) { - next if (!exists $hourly_count{"$h:$rd"}); - $details .= "$zday$h:$rd" . - &comma_numbers($hourly_count{"$h:$rd"}) . "" . - &convert_time($hourly_duration{"$h:$rd"}) . "" . - &convert_time($hourly_duration{"$h:$rd"}/($hourly_count{"$h:$rd"}||1)) . ""; + if ($#histo_avgs > 0) { + foreach my $rd (@histo_avgs) { + next if (!exists $hourly_count{"$h:$rd"}); + $details .= "$zday$h:$rd" . + &comma_numbers($hourly_count{"$h:$rd"}) . "" . + &convert_time($hourly_duration{"$h:$rd"}) . "" . + &convert_time($hourly_duration{"$h:$rd"}/($hourly_count{"$h:$rd"}||1)) . ""; + } } } } @@ -7326,10 +7332,12 @@ sub show_error_as_html my $rd = &average_per_minutes($m, $histo_avg_minutes); $hourly_count{"$h:$rd"} += $error_info{$k}{chronos}{$d}{$h}{min}{$m}; } - foreach my $rd (@histo_avgs) { - next if (!exists $hourly_count{"$h:$rd"}); - $details .= "$zday$h:$rd" . - &comma_numbers($hourly_count{"$h:$rd"}) . ""; + if ($#histo_avgs > 0) { + foreach my $rd (@histo_avgs) { + next if (!exists $hourly_count{"$h:$rd"}); + $details .= "$zday$h:$rd" . + &comma_numbers($hourly_count{"$h:$rd"}) . ""; + } } } }