[Git][qa/jenkins.debian.net][master] djm: improve algorithm to calculate hours worked
Holger Levsen (@holger)
gitlab at salsa.debian.org
Wed Nov 1 17:26:00 GMT 2023
Holger Levsen pushed to branch master at Debian QA / jenkins.debian.net
Commits:
625b3d19 by Holger Levsen at 2023-11-01T18:24:50+01:00
djm: improve algorithm to calculate hours worked
Signed-off-by: Holger Levsen <holger at layer-acht.org>
- - - - -
1 changed file:
- bin/djm
Changes:
=====================================
bin/djm
=====================================
@@ -349,11 +349,25 @@ djm_report() {
cat $LOCAL_LOGFILE $UI_LOGFILE | grep ^$LOGMONTH | sort -u > $TMP_LOGFILE
TOTAL_ACTIONS=$(grep -c ^$LOGMONTH $TMP_LOGFILE)
HOSTS=$(cut -d ',' -f2 $TMP_LOGFILE | sort -u | grep -v "web UI"| wc -l)
+ TMP_WORKLOG=$(mktemp)
+ ( for point_in_time in $(cat $TMP_LOGFILE | cut -d ' ' -f1-2 | sort -u | sed -e 's#-##g' -e 's# ##g' -e 's#:##g' ) ; do
+ x=$(( $point_in_time - 10 ))
+ y=$(( $point_in_time + 15 ))
+ for each_minute in $(seq $x $y) ; do
+ echo $each_minute
+ done
+ done ) | sort -u >> $TMP_WORKLOG
+ TOTAL_HOURS=0
+ for point_in_time in $(cat $TMP_WORKLOG | cut -b 1-8 | sort -u) ; do
+ echo -n "$point_in_time: "
+ minutes=$(grep -c ^$point_in_time $TMP_WORKLOG)
+ half_hours=$(( (30+$minutes)/30 ))
+ hours=$(echo "scale=1 ; $half_hours/2" | bc)
+ TOTAL_HOURS=$(echo "scale=1 ; $TOTAL_HOURS+$hours" | bc)
+ echo "${hours}h - ${TOTAL_HOURS}h"
+ done
+ rm $TMP_WORKLOG
HOURS=$(cut -b 1-13 $TMP_LOGFILE | sort -u | wc -l)
- TEN_MIN_SLICES=$(cut -b 1-15 $TMP_LOGFILE | sort -u | wc -l)
- TWENTY_MIN_SLICES=$(( TEN_MIN_SLICES + TEN_MIN_SLICES )) # this is too simplefied and has false positives
- TEN_SLICES_AS_HOURS=$(($TEN_MIN_SLICES/6))
- TWEN_SLICES_AS_HOURS=$(($TWENTY_MIN_SLICES/3))
# create sorted list of actions/reasons (sorted by amount of occurances)
# the character '%" is solely used as a delimeter for cut later
# the character '=' is added so later we can use a for-loop without dealing with $IFS
@@ -374,10 +388,7 @@ djm_report() {
printf "$TWO_C" "jenkins jobs maintained:" "$(cat $JOBS)"
seperator
printf "$TWO_C" "hours with djm usage:" "${HOURS}"
- printf "$TWO_C" " ten minute slices with djm usage:" "$TEN_MIN_SLICES"
- printf "$TWO_C" " - thoses slices as hours:" "${TEN_SLICES_AS_HOURS}"
- printf "$TWO_C" " twenty minute slices (because focus):" "$TWENTY_MIN_SLICES"
- printf "$TWO_C" " - thoses slices as hours:" "${TWEN_SLICES_AS_HOURS}"
+ printf "$TWO_C" "hours worked:" "${TOTAL_HOURS}"
seperator "="
printf "$ONE_C" "actions:"
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/625b3d19207a15d6c9458482e368aa480826a196
--
View it on GitLab: https://salsa.debian.org/qa/jenkins.debian.net/-/commit/625b3d19207a15d6c9458482e368aa480826a196
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/20231101/ba572b9b/attachment-0001.htm>
More information about the Qa-jenkins-scm
mailing list