Merge branch 'dev'
This commit is contained in:
commit
20300c8d72
55
cv
55
cv
@ -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
|
||||||
@ -10,7 +10,7 @@ country=$1
|
|||||||
[ -z $ydate ] && ydate=$(date -d yesterday $dfmt)
|
[ -z $ydate ] && ydate=$(date -d yesterday $dfmt)
|
||||||
|
|
||||||
# Get yesterday's stats for queries after midnight.
|
# Get yesterday's stats for queries after midnight.
|
||||||
if [ "$2" == "yesterday" ]
|
if [ ! -z $2 ]
|
||||||
then
|
then
|
||||||
date=$(date -d yesterday $dfmt)
|
date=$(date -d yesterday $dfmt)
|
||||||
ydate=$(date -d "2 days ago" $dfmt)
|
ydate=$(date -d "2 days ago" $dfmt)
|
||||||
@ -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(){
|
||||||
printf "║ %-${w}s ║ %${w}s ║ %-${w}s ║\n" "" "$(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
|
||||||
@ -47,36 +47,39 @@ yget(){
|
|||||||
echo 0
|
echo 0
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
stats(){
|
||||||
|
out "$1:" "$(get $2)" "+ $(echo "scale = 2; $(get $2) - $(yget $2)" | bc)"
|
||||||
|
}
|
||||||
out(){
|
out(){
|
||||||
printf "║ %-${w}s ║ %${w}s ║ %-${w}s ║\n" "$1:" "$(get $2)" "+ $(echo "scale = 2; $(get $2) - $(yget $2)" | bc)"
|
printf "║ %-${w}s ║ %${w}s ║ %-${w}s ║\n" "$1" "$2" "$3"
|
||||||
}
|
}
|
||||||
frame(){
|
frame(){
|
||||||
case "$1" in
|
case "$1" in
|
||||||
top) printf "╔═════════════════════════════════════════╗\n" ;;
|
top) printf "╔══════════════════════════════════════════════════╗\n" ;;
|
||||||
table) printf "║ Statistic ║ Today ║ Yesterday ║\n"
|
sep) printf "╟────────────────╫────────────────╫────────────────╢\n" ;;
|
||||||
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(){
|
||||||
frame top
|
frame top
|
||||||
title "Queried at: $date"
|
title "Queried at $date for $(get country)."
|
||||||
frame up
|
frame up
|
||||||
frame table
|
out Statistic Today Yesterday
|
||||||
out Total cases
|
frame sep
|
||||||
out "╰> Per 1M " casesPerOneMillion
|
stats Total cases
|
||||||
out Active active
|
getpm casesPerOneMillion
|
||||||
out Critical critical
|
stats New todayCases
|
||||||
out New todayCases
|
frame sep
|
||||||
out Deaths deaths
|
stats Active active
|
||||||
out "╰> Per 1M " deathsPerOneMillion
|
stats Critical critical
|
||||||
out Recovered recovered
|
stats Deaths deaths
|
||||||
out Tests tests
|
getpm deathsPerOneMillion
|
||||||
out "╰> Per 1M " testsPerOneMillion
|
stats Recovered recovered
|
||||||
getpct testsPerOneMillion
|
stats Tests tests
|
||||||
|
getpm testsPerOneMillion
|
||||||
if [ ! -f $data/$ydate-$country ] || [ $(get todayCases) == "0" ]
|
if [ ! -f $data/$ydate-$country ] || [ $(get todayCases) == "0" ]
|
||||||
then
|
then
|
||||||
frame line
|
frame line
|
||||||
|
Reference in New Issue
Block a user