[Qa-jenkins-scm] [Git][qa/jenkins.debian.net][master] reproducible debian: round the result of bc in the dashboard stats
Mattia Rizzolo (@mattia)
gitlab at salsa.debian.org
Wed Oct 5 17:01:42 BST 2022
Mattia Rizzolo pushed to branch master at Debian QA / jenkins.debian.net
Commits:
b153a66d by Mattia Rizzolo at 2022-10-05T18:01:13+02:00
reproducible debian: round the result of bc in the dashboard stats
Signed-off-by: Mattia Rizzolo <mattia at debian.org>
- - - - -
2 changed files:
- bin/reproducible_common.sh
- bin/reproducible_html_dashboard.sh
Changes:
=====================================
bin/reproducible_common.sh
=====================================
@@ -2,7 +2,7 @@
# vim: set noexpandtab:
# Copyright 2014-2022 Holger Levsen <holger at layer-acht.org>
-# © 2015-2018 Mattia Rizzolo <mattia at mapreri.org>
+# © 2015-2022 Mattia Rizzolo <mattia at mapreri.org>
# released under the GPLv2
#
# included by all reproducible_*.sh scripts, so be quiet
@@ -152,6 +152,14 @@ delay_start() {
/bin/sleep $(echo "scale=1 ; $(shuf -i 1-230 -n 1)/10" | bc )
}
+bc_round() {
+ # comes from https://stackoverflow.com/a/26864946
+ # $1 is expression to round (should be a valid bc expression)
+ # $2 is number of decimal figures (optional). Defaults to one if none given
+ local df=${2:-1}
+ printf '%.*f\n' "$df" "$(bc -l <<< "a=$1; if(a>0) a+=5/10^($df+1) else if (a<0) a-=5/10^($df+1); scale=$df; a/1")"
+}
+
schedule_packages() {
LC_USER="$REQUESTER" \
LOCAL_CALL="true" \
=====================================
bin/reproducible_html_dashboard.sh
=====================================
@@ -2,7 +2,7 @@
# vim: set noexpandtab:
# Copyright 2014-2022 Holger Levsen <holger at layer-acht.org>
-# © 2015 Mattia Rizzolo <mattia at mapreri.org>
+# © 2015-2022 Mattia Rizzolo <mattia at mapreri.org>
# released under the GPLv2
DEBUG=false
@@ -206,16 +206,16 @@ gather_suite_arch_stats() {
COUNT_BLACKLISTED=$(query_db "SELECT COUNT(s.name) FROM results AS r JOIN sources AS s ON r.package_id=s.id WHERE s.suite='$SUITE' AND s.architecture='$ARCH' AND r.status = 'blacklisted'")
COUNT_DEPWAIT=$(query_db "SELECT COUNT(s.name) FROM results AS r JOIN sources AS s ON r.package_id=s.id WHERE s.suite='$SUITE' AND s.architecture='$ARCH' AND r.status = 'depwait'")
COUNT_OTHER=$(( $COUNT_SOURCELESS+$COUNT_NOTFORUS+$COUNT_BLACKLISTED+$COUNT_DEPWAIT+$COUNT_TIMEOUT ))
- PERCENT_TOTAL=$(echo "scale=1 ; ($COUNT_TOTAL*100/$AMOUNT)" | bc)
- PERCENT_GOOD=$(echo "scale=1 ; ($COUNT_GOOD*100/$COUNT_TOTAL)" | bc || echo 0)
- PERCENT_BAD=$(echo "scale=1 ; ($COUNT_BAD*100/$COUNT_TOTAL)" | bc || echo 0)
- PERCENT_UGLY=$(echo "scale=1 ; ($COUNT_UGLY*100/$COUNT_TOTAL)" | bc || echo 0)
- PERCENT_TIMEOUT=$(echo "scale=1 ; ($COUNT_TIMEOUT*100/$COUNT_TOTAL)" | bc || echo 0)
- PERCENT_NOTFORUS=$(echo "scale=1 ; ($COUNT_NOTFORUS*100/$COUNT_TOTAL)" | bc || echo 0)
- PERCENT_DEPWAIT=$(echo "scale=1 ; ($COUNT_DEPWAIT*100/$COUNT_TOTAL)" | bc || echo 0)
- PERCENT_SOURCELESS=$(echo "scale=1 ; ($COUNT_SOURCELESS*100/$COUNT_TOTAL)" | bc || echo 0)
- PERCENT_BLACKLISTED=$(echo "scale=1 ; ($COUNT_BLACKLISTED*100/$COUNT_TOTAL)" | bc || echo 0)
- PERCENT_OTHER=$(echo "scale=1 ; ($COUNT_OTHER*100/$COUNT_TOTAL)" | bc || echo 0)
+ PERCENT_TOTAL=$(bc_round "($COUNT_TOTAL*100/$AMOUNT)")
+ PERCENT_GOOD=$(bc_round "($COUNT_GOOD*100/$COUNT_TOTAL)" || echo 0)
+ PERCENT_BAD=$(bc_round "$COUNT_BAD*100/$COUNT_TOTAL)" || echo 0)
+ PERCENT_UGLY=$(bc_round "($COUNT_UGLY*100/$COUNT_TOTAL)" || echo 0)
+ PERCENT_TIMEOUT=$(bc_round "($COUNT_TIMEOUT*100/$COUNT_TOTAL)" || echo 0)
+ PERCENT_NOTFORUS=$(bc_round "($COUNT_NOTFORUS*100/$COUNT_TOTAL)" || echo 0)
+ PERCENT_DEPWAIT=$(bc_round "($COUNT_DEPWAIT*100/$COUNT_TOTAL)" || echo 0)
+ PERCENT_SOURCELESS=$(bc_round "($COUNT_SOURCELESS*100/$COUNT_TOTAL)" || echo 0)
+ PERCENT_BLACKLISTED=$(bc_round "($COUNT_BLACKLISTED*100/$COUNT_TOTAL)" || echo 0)
+ PERCENT_OTHER=$(bc_round "($COUNT_OTHER*100/$COUNT_TOTAL)" || echo 0)
}
#
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/b153a66d5281d0ea7e1d48aef1b03e3fa4af6f78
--
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/b153a66d5281d0ea7e1d48aef1b03e3fa4af6f78
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/qa-jenkins-scm/attachments/20221005/1b01066a/attachment-0001.htm>
More information about the Qa-jenkins-scm
mailing list