Add support for querying yesterday's stats
This commit is contained in:
parent
e25cb844e4
commit
bdc96c74ec
19
cv
19
cv
@ -6,6 +6,7 @@ then
|
|||||||
else
|
else
|
||||||
# This is a compatibility mode and not well-supported.
|
# This is a compatibility mode and not well-supported.
|
||||||
date=$(date +"%Y-%m-%d")
|
date=$(date +"%Y-%m-%d")
|
||||||
|
ydate=$(date -d yesterday +"%Y-%m-%d")
|
||||||
show(){
|
show(){
|
||||||
echo -e "\033[1;36m> ${@} \033[0m"
|
echo -e "\033[1;36m> ${@} \033[0m"
|
||||||
}
|
}
|
||||||
@ -31,16 +32,32 @@ get(){
|
|||||||
cat $data/$date-$country
|
cat $data/$date-$country
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
yget(){
|
||||||
|
date=$ydate
|
||||||
|
get
|
||||||
|
}
|
||||||
result(){
|
result(){
|
||||||
echo "Total: $(get | jq -r '.cases')"
|
echo "Total: $(get | jq -r '.cases')"
|
||||||
echo "Active: $(get | jq -r '.active')"
|
echo "Active: $(get | jq -r '.active')"
|
||||||
echo "Today: $(get | jq -r '.todayCases')"
|
echo "New: $(get | jq -r '.todayCases')"
|
||||||
echo "Tests: $(get | jq -r '.tests')"
|
echo "Tests: $(get | jq -r '.tests')"
|
||||||
|
show "Yesterday's stats:"
|
||||||
|
echo "New: $(yget | jq -r '.todayCases')"
|
||||||
if [ $(get | jq -r '.todayCases') == "0" ]
|
if [ $(get | jq -r '.todayCases') == "0" ]
|
||||||
then
|
then
|
||||||
show "Seems like the cases today are not yet updated."
|
show "Seems like the cases today are not yet updated."
|
||||||
show "The data file will be removed. Please query again later."
|
show "The data file will be removed. Please query again later."
|
||||||
ex "rm $data/$date-$country"
|
ex "rm $data/$date-$country"
|
||||||
|
elif [ $(get | jq -r '.todayCases') == $(yget | jq -r '.todayCases') ]
|
||||||
|
then
|
||||||
|
show "Seems like the stats are the same as yesterday."
|
||||||
|
show "This could be normal but may mean that the data file is still yesterday's."
|
||||||
|
show "Do you want to remove it? (y/n)"
|
||||||
|
read answer
|
||||||
|
if [ "$answer" == "y" ]
|
||||||
|
then
|
||||||
|
ex "rm $data/$date-$country"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user