-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuilds.sh
More file actions
executable file
·62 lines (55 loc) · 1.45 KB
/
builds.sh
File metadata and controls
executable file
·62 lines (55 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#!/bin/bash
# Author: Logan Isitt
date=
project=
function displaytime {
local T=$1
local M=$((T/60))
local S=$((T%60))
[[ $M > 0 ]] && printf '%d minutes' $M
[[ $M > 0 ]] && [[ $S > 0 ]] && printf ' and '
[[ $S > 0 ]] && printf '%d seconds' $S
}
function usage {
echo "usage: $(basename "$0") [-p project] [-d date] [-h]"
echo "date format: YYYY-mm-dd"
}
while [ "$1" != "" ]; do
case $1 in
-p | --project ) shift
project=$1
;;
-d | --date ) shift
date=$1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
read parY parM parD rest<<< ${date//[-: ]/ }
while IFS="," read a p d t;
do
if [ "$date" != "" ]; then
read logY logM logD rest<<< ${d//[-: ]/ }
if [ "$logY" != "$parY" ] || [ "$logM" != "$parM" ] || [ "$logD" != "$parD" ]; then
continue
fi
fi
if [ "$project" != "" ]; then
if [ "$project" != $p ]; then
continue
fi
fi
sum=$((sum + t))
count=$((count + 1))
if [ "$longest" == "" ] || [ $t -gt $longest ]; then
longest=$((t))
fi
done < buildlog.csv
echo "Total: " $(displaytime $sum)
echo "Average: " $(displaytime $((sum / count)))
echo "Longest: " $(displaytime $longest)