From: Darold Gilles Date: Sat, 14 Jun 2014 02:06:22 +0000 (+0200) Subject: Fix incremental mode where weeks on index page start on sunday and week reports start... X-Git-Tag: v6.0~34 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=9315365057bde93363d916ff927bd4526862b885;p=pgbadger Fix incremental mode where weeks on index page start on sunday and week reports start on monday. Thanks to flopma and birkosan for the report. --- diff --git a/pgbadger b/pgbadger index 095e93d..45c790f 100644 --- a/pgbadger +++ b/pgbadger @@ -3509,13 +3509,13 @@ sub print_general_activity $count $min $max - $average} ; - foreach my $lp (@LATENCY_PERCENTILE) { - $queries .= - qq{ - $percentile{$lp} }; - }; - $queries .= qq{}; + $average +}; + foreach my $lp (@LATENCY_PERCENTILE) { + $queries .= "$percentile{$lp}\n"; + } + $queries .= qq{ + }; $count = &comma_numbers($cur_period_info{'SELECT'}{count}); $average = &convert_time($cur_period_info{'SELECT'}{average}); $select_queries .= qq{ @@ -3523,13 +3523,13 @@ sub print_general_activity $zday $h $count - $average} ; - foreach my $lp (@LATENCY_PERCENTILE) { - $select_queries .= - qq{ - $percentile{'SELECT'}{$lp} }; - }; - $select_queries .= qq{}; + $average +}; + foreach my $lp (@LATENCY_PERCENTILE) { + $select_queries .= "$percentile{'SELECT'}{$lp}\n"; + } + $select_queries .= qq{ + }; my $insert_count = &comma_numbers($cur_period_info{'INSERT'}{count}); my $update_count = &comma_numbers($cur_period_info{'UPDATE'}{count}); my $delete_count = &comma_numbers($cur_period_info{'DELETE'}{count}); @@ -3542,12 +3542,11 @@ sub print_general_activity $update_count $delete_count $write_average} ; - foreach my $lp (@LATENCY_PERCENTILE) { - $write_queries .= - qq{ - $percentile{'WRITE'}{$lp} }; - }; - $write_queries .= qq{}; + foreach my $lp (@LATENCY_PERCENTILE) { + $write_queries .= "$percentile{'WRITE'}{$lp}\n"; + } + $write_queries .= qq{ + }; my $prepare_count = &comma_numbers($cur_period_info{prepare}); my $execute_count = &comma_numbers($cur_period_info{execute}); my $bind_prepare = &comma_numbers(sprintf("%.2f", $cur_period_info{execute}/($cur_period_info{prepare}||1))); @@ -10373,7 +10372,7 @@ sub get_week_number if ($datefmt ne "$year-$month-$day") { return -1; } - my $weekNumber = POSIX::strftime("%W", 1, 1, 1, $day, $month - 1, $year - 1900); + my $weekNumber = POSIX::strftime("%U", 1, 1, 1, $day, $month - 1, $year - 1900); return sprintf("%02d", $weekNumber+1); } @@ -10422,7 +10421,7 @@ sub get_wdays_per_month if ($datefmt ne "$y-$m-$day") { next; } - my $weekNumber = POSIX::strftime("%W", 1, 1, 1, $day, $m - 1, $y - 1900); + my $weekNumber = POSIX::strftime("%U", 1, 1, 1, $day, $m - 1, $y - 1900); if ( ($weekNumber == $wn) || ( ($weekNumber eq '00') && (($wn == 1) || ($wn >= 52)) ) ) { push(@retdays, "$year-$m-$day"); return @retdays if ($#retdays == 6); @@ -10447,7 +10446,7 @@ sub get_wdays_per_year if ($datefmt ne "$y-$m-$day") { next; } - my $weekNumber = POSIX::strftime("%W", 1, 1, 1, $day, $m - 1, $y - 1900); + my $weekNumber = POSIX::strftime("%U", 1, 1, 1, $day, $m - 1, $y - 1900); push(@{$result{$weekNumber}}, "$y-$m-$day"); } }