update commitsByWeekday sorting

Fix inconsistent sum sorting in by-weekday, #91
This commit is contained in:
Lukáš Mešťan
2020-02-14 09:34:46 +01:00
committed by GitHub
parent ed0e3cbb6b
commit 24ae67ae57

View File

@@ -377,21 +377,21 @@ function commitsByMonth() {
function commitsByWeekday() { function commitsByWeekday() {
optionPicked "Git commits by weekday:" optionPicked "Git commits by weekday:"
echo -e "\tday\tsum" echo -e "\tday\tsum"
local counter=1
for i in Mon Tue Wed Thu Fri Sat Sun for i in Mon Tue Wed Thu Fri Sat Sun
do do
echo -en "\t$i\t" echo -en "\t$counter\t$i\t"
git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \ git -c log.showSignature=false shortlog -n $_merges --format='%ad %s' \
$_since $_until | grep "$i " | wc -l $_since $_until | grep "$i " | wc -l
counter=$((counter+1))
done | awk '{ done | awk '{
} }
NR == FNR { NR == FNR {
count[$1] = $2; count[$1" "$2] = $3;
total += $2; total += $3;
next next
} }
END{ END{
for (day in count) { for (day in count) {
s="|"; s="|";
if (total > 0) { if (total > 0) {
@@ -399,10 +399,10 @@ function commitsByWeekday() {
for (i = 1; i <= percent; ++i) { for (i = 1; i <= percent; ++i) {
s=s"█" s=s"█"
} }
printf( "\t%s\t%-0s\t%s\n", day, count[day], s ); printf("\t%s\t%s\t%-0s\t%s\n", substr(day,0,1), substr(day,3,5), count[day], s);
} }
} }
}' | sort -k 2 -n -r }' | sort -k 1 -n | awk '{$1=""}1' | awk '{$1=$1}1' | awk '{printf("\t%s\t%s\t%s\n", $1, $2, $3)}'
} }
################################################################################ ################################################################################