[PR] index: do not round the failometer bar widths (PR #7)

Kacper Michajłow via ffmpeg-devel <[email protected]>
Newsgroups gmane.comp.video.ffmpeg.devel
Message-ID <178681062940.59.1000100967005920192@29965ddac10e>
PR #7 opened by Kacper Michajłow (kasper93)
URL: https://code.ffmpeg.org/FFmpeg/fateserver/pulls/7
Patch URL: https://code.ffmpeg.org/FFmpeg/fateserver/pulls/7.patch

Rounding the three percentages could sum to 100.1%, and the progress
element hides what does not fit. Instead just round the values in
tooltips.


From db731eddc4f1d21de2aae141a84dc285e6e5bc13 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Kacper=20Michaj=C5=82ow?= <[email protected]>
Date: Sat, 15 Aug 2026 17:49:57 +0200
Subject: [PATCH] index: do not round the failometer bar widths
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Rounding the three percentages could sum to 100.1%, and the progress
element hides what does not fit. Instead just round the values in
tooltips.

Signed-off-by: Kacper Michajłow <[email protected]>
---
 index.cgi | 30 +++++++++++++-----------------
 1 file changed, 13 insertions(+), 17 deletions(-)

diff --git a/index.cgi b/index.cgi
index 36dc5e1..8b57fc5 100755
--- a/index.cgi
+++ b/index.cgi
@@ -110,17 +110,13 @@ my $clear = '?' . join '&', other_params();
                          'Clear all search criteria.</a>' :
                          'No data in $fatedir.';
 
-# Percentage of $n out of $total, rounded to one decimal for display.
-sub pct {
-    my ($n, $total) = @_;
-    return int(1000 * $n / $total + 0.5) / 10;
-}
-
-my $nreps = @reps;
-my $warn = $nreps - $allpass - $allfail;
-$allpass = pct($allpass, $nreps);
-$allfail = pct($allfail, $nreps);
-$warn    = pct($warn,    $nreps);
+my $warn = @reps - $allpass - $allfail;
+$allpass = 100 * $allpass / @reps;
+$allfail = 100 * $allfail / @reps;
+$warn    = 100 * $warn / @reps;
+my $passpc = sprintf '%.1f', $allpass;
+my $failpc = sprintf '%.1f', $allfail;
+my $warnpc = sprintf '%.1f', $warn;
 
 my @sort = ('result', 'subarch', 'os', 'cc', 'comment', 'slot');
 defined $sort and unshift @sort, split /\/\//, $sort;
@@ -279,22 +275,22 @@ start 'td', colspan => 8, id => 'failometer';
 start 'div', class => 'progress';
 if ($allpass) {
     print <<EOF;
-<div class="progress-bar pass" role="progressbar" title="${allpass}% tests passed" aria-valuenow="${allpass}" aria-valuemin="0" aria-valuemax="100" style="width: ${allpass}%">
-  <span class="sr-only">${allpass}%</span>
+<div class="progress-bar pass" role="progressbar" title="${passpc}% tests passed" aria-valuenow="${passpc}" aria-valuemin="0" aria-valuemax="100" style="width: ${allpass}%">
+  <span class="sr-only">${passpc}%</span>
 </div>
 EOF
 }
 if ($warn) {
     print <<EOF;
-<div class="progress-bar warn" role="progressbar" title="${warn}% tests failed" aria-valuenow="${warn}" aria-valuemin="0" aria-valuemax="100" style="width: ${warn}%">
-  <span class="sr-only">${warn}%</span>
+<div class="progress-bar warn" role="progressbar" title="${warnpc}% tests failed" aria-valuenow="${warnpc}" aria-valuemin="0" aria-valuemax="100" style="width: ${warn}%">
+  <span class="sr-only">${warnpc}%</span>
 </div>
 EOF
 }
 if ($allfail) {
     print <<EOF;
-<div class="progress-bar fail" role="progressbar" title="${allfail}% build failed" aria-valuenow="${allfail}" aria-valuemin="0" aria-valuemax="100" style="width: ${allfail}%">
-  <span class="sr-only">${allfail}%</span>
+<div class="progress-bar fail" role="progressbar" title="${failpc}% build failed" aria-valuenow="${failpc}" aria-valuemin="0" aria-valuemax="100" style="width: ${allfail}%">
+  <span class="sr-only">${failpc}%</span>
 </div>
 EOF
 }
-- 
2.52.0

_______________________________________________
ffmpeg-devel mailing list -- [email protected]
To unsubscribe send an email to [email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.