[Qa-jenkins-scm] [jenkins.debian.net] 02/02: reproducible debian: html_dashboard: DRY: factor out _average_builds_per_day and automatically deal with auto-hiding stats for very new archs
Holger Levsen
holger at layer-acht.org
Thu Jan 19 12:21:38 UTC 2017
This is an automated email from the git hooks/post-receive script.
holger pushed a commit to branch master
in repository jenkins.debian.net.
commit 63dd7188c7608c7f90a0e4d2b2e4ed2d4ae5baf7
Author: Mattia Rizzolo <mattia at debian.org>
Date: Thu Jan 19 11:56:24 2017 +0100
reproducible debian: html_dashboard: DRY: factor out _average_builds_per_day and automatically deal with auto-hiding stats for very new archs
Signed-off-by: Holger Levsen <holger at layer-acht.org>
---
bin/reproducible_html_dashboard.sh | 64 ++++++++++++++++++++------------------
1 file changed, 33 insertions(+), 31 deletions(-)
diff --git a/bin/reproducible_html_dashboard.sh b/bin/reproducible_html_dashboard.sh
index c5d19e3..fdbeb7e 100755
--- a/bin/reproducible_html_dashboard.sh
+++ b/bin/reproducible_html_dashboard.sh
@@ -294,6 +294,35 @@ write_usertag_table() {
#
# write build performance stats
#
+_average_builds_per_day() {
+ local TIMESPAN_RAW="$1"
+ local TIMESPAN_VERBOSE="$2"
+ local MIN_DAYS="${3-0}"
+ write_page "<tr><td class=\"left\">packages tested on average per day in the last $TIMESPAN_VERBOSE</td>"
+ for ARCH in ${ARCHS} ; do
+ local OLDEST_BUILD="$(query_db "SELECT build_date FROM stats_build WHERE architecture='$ARCH' ORDER BY build_date ASC LIMIT 1")"
+ local DAY_DIFFS="$(( ($(date -d "$DATE" +%s) - $(date -d "$OLDEST_BUILD" +%s)) / (60*60*24) ))"
+ if [ $DAY_DIFFS -lt $TIMESPAN_RAW ]; then
+ # this is a new architecture, there are fewer days to compare to.
+ local DISCLAIMER=" <span style=\"font-size: 0.8em;\">(in the last $DAY_DIFFS days)</span>"
+ TIMESPAN_RAW=$DAY_DIFF
+ fi
+ if [ $DAY_DIFFS -ge $MIN_DAYS ]; then
+ # find stats for since the day before $TIMESPAN_RAW days ago,
+ # since no stats exist for today yet.
+ local TIMESPAN="$(echo $TIMESPAN_RAW-1|bc)"
+ local TIMESPAN_DATE=$(date '+%Y-%m-%d %H:%M' -d "- $TIMESPAN days")
+
+ RESULT=$(query_db "SELECT COUNT(r.build_date) FROM stats_build AS r WHERE r.build_date > '$TIMESPAN_DATE' AND r.architecture='$ARCH'")
+ RESULT="$(echo $RESULT/$TIMESPAN_RAW|bc)"
+ else
+ # very new arch with too few resulsts to care about stats
+ RESULT=" "
+ fi
+ write_page "<td>${RESULT}${DISCLAIMER:-}</td>"
+ done
+ write_page "</tr>"
+}
write_build_performance_stats() {
local ARCH
write_page "<table class=\"main\"><tr><th>Architecture build statistics</th>"
@@ -340,39 +369,12 @@ write_build_performance_stats() {
RESULT=$(query_db "SELECT COUNT(r.build_date) FROM stats_build AS r WHERE r.build_date > '$(date '+%Y-%m-%d %H:%M' -d '-1 days')' AND r.architecture='$ARCH'")
write_page "<td>$RESULT</td>"
done
- write_page "</tr><tr><td class=\"left\">packages tested on average per day in the last $TIMESPAN_VERBOSE</td>"
- for ARCH in ${ARCHS} ; do
- local OLDEST_BUILD="$(query_db "SELECT build_date FROM stats_build WHERE architecture='$ARCH' ORDER BY build_date ASC LIMIT 1")"
- local DAY_DIFFS="$(( ($(date -d "$DATE" +%s) - $(date -d "$OLDEST_BUILD" +%s)) / (60*60*24) ))"
- if [ $DAY_DIFFS -lt $TIMESPAN_RAW ]; then
- # this is a new architecture, there are fewer days to compare to.
- local DISCLAIMER=" <span style=\"font-size: 0.8em;\">(in the last $DAY_DIFFS days)</span>"
- TIMESPAN_RAW=$DAY_DIFF
- fi
- local TIMESPAN="$(echo $TIMESPAN_RAW-1|bc)"
- local TIMESPAN_DATE=$(date '+%Y-%m-%d %H:%M' -d "- $TIMESPAN days")
-
- RESULT=$(query_db "SELECT COUNT(r.build_date) FROM stats_build AS r WHERE r.build_date > '$TIMESPAN_DATE' AND r.architecture='$ARCH'")
- RESULT="$(echo $RESULT/$TIMESPAN_RAW|bc)"
- write_page "<td>${RESULT}${DISCLAIMER:-}</td>"
- done
+ write_page "</tr>"
+ _average_builds_per_day "$TIMESTAMP_RAW" "$TIMESTAMP_VERBOSE"
+ _average_builds_per_day "91" "3 months" "30"
- local TIMESPAN_VERBOSE="3 months"
- local TIMESPAN_RAW="91"
- # Find stats for 91 days since yesterday, no stats exist for today
- local TIMESPAN="$(echo $TIMESPAN_RAW-1|bc)"
- local TIMESPAN_DATE=$(date '+%Y-%m-%d %H:%M' -d "- $TIMESPAN days")
- write_page "</tr><tr><td class=\"left\">packages tested on average per day in the last $TIMESPAN_VERBOSE</td>"
- for ARCH in ${ARCHS} ; do
- RESULT=$(query_db "SELECT COUNT(r.build_date) FROM stats_build AS r WHERE r.build_date > '$TIMESPAN_DATE' AND r.architecture='$ARCH'")
- RESULT="$(echo $RESULT/$TIMESPAN_RAW|bc)"
- if [ "$ARCH" = "arm64" ] ; then
- RESULT=" "
- fi
- write_page "<td>$RESULT</td>"
- done
- write_page "</tr></table>"
+ write_page "</table>"
}
#
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/qa/jenkins.debian.net.git
More information about the Qa-jenkins-scm
mailing list