Merge percentage and per 1M stats

This commit is contained in:
Michael De Roover 2020-08-14 16:21:50 +02:00
parent 5bbfc4ad77
commit 36c655cec0
Signed by: vim
GPG Key ID: 075496E232CE04CB

27
cv
View File

@ -1,7 +1,7 @@
#!/bin/bash #!/bin/bash
# Variable declarations go here. # Variable declarations go here.
w=11 w=14
dfmt="+%Y-%m-%d" dfmt="+%Y-%m-%d"
data="$HOME/Documents/cv" data="$HOME/Documents/cv"
country=$1 country=$1
@ -22,7 +22,7 @@ ex(){
$@ $@
} }
title(){ title(){
local w=39 local w=48
printf "║ %-${w}s ║\n" "${*}" printf "║ %-${w}s ║\n" "${*}"
} }
@ -35,8 +35,8 @@ get(){
jq -r ".$1" < "$data/$date-$country" jq -r ".$1" < "$data/$date-$country"
fi fi
} }
getpct(){ getpm(){
out "" "$(echo "$(bc <<< "scale = 1; $(get $1) / 10000") %")" "" out "╰> Per 1M " "$(get $1) ($(echo "$(bc <<< "scale = 1; $(get $1) / 10000")%"))" ""
} }
yget(){ yget(){
date=$ydate date=$ydate
@ -55,13 +55,13 @@ out(){
} }
frame(){ frame(){
case "$1" in case "$1" in
top) printf "╔═════════════════════════════════════════╗\n" ;; top) printf "╔══════════════════════════════════════════════════╗\n" ;;
title) printf "║ Statistic ║ Today ║ Yesterday ║\n" ;; title) printf "║ Statistic ║ Today ║ Yesterday ║\n" ;;
sep) printf "╟─────────────╫─────────────╫─────────────╢\n" ;; sep) printf "╟────────────────────────────────╫────────────────╢\n" ;;
up) printf "╠═════════════╦═════════════╦═════════════╣\n" ;; up) printf "╠════════════════════════════════╦════════════════╣\n" ;;
down) printf "╚═════════════╩═════════════╩═════════════╝\n" ;; down) printf "╚════════════════════════════════╩════════════════╝\n" ;;
line) printf "╠═════════════╩═════════════╩═════════════╣\n" ;; line) printf "╠════════════════════════════════╩════════════════╣\n" ;;
bot) printf "╚═════════════════════════════════════════╝\n" ;; bot) printf "╚══════════════════════════════════════════════════╝\n" ;;
esac esac
} }
result(){ result(){
@ -71,17 +71,16 @@ result(){
frame title frame title
frame sep frame sep
stats Total cases stats Total cases
stats "╰> Per 1M " casesPerOneMillion getpm casesPerOneMillion
stats New todayCases stats New todayCases
frame sep frame sep
stats Active active stats Active active
stats Critical critical stats Critical critical
stats Deaths deaths stats Deaths deaths
stats "╰> Per 1M " deathsPerOneMillion getpm deathsPerOneMillion
stats Recovered recovered stats Recovered recovered
stats Tests tests stats Tests tests
stats "╰> Per 1M " testsPerOneMillion getpm testsPerOneMillion
getpct testsPerOneMillion
if [ ! -f $data/$ydate-$country ] || [ $(get todayCases) == "0" ] if [ ! -f $data/$ydate-$country ] || [ $(get todayCases) == "0" ]
then then
frame line frame line