Optimize get
This commit is contained in:
parent
b2e153da39
commit
34dbc57e75
20
cv
20
cv
@ -26,29 +26,29 @@ country=$1
|
|||||||
get(){
|
get(){
|
||||||
if [ -f $data/$date-$country ]
|
if [ -f $data/$date-$country ]
|
||||||
then
|
then
|
||||||
cat $data/$date-$country
|
cat $data/$date-$country | jq -r .$1
|
||||||
else
|
else
|
||||||
curl -sL corona.lmao.ninja/v2/$endpoint > $data/$date-$country
|
curl -sL corona.lmao.ninja/v2/$endpoint > $data/$date-$country
|
||||||
cat $data/$date-$country
|
cat $data/$date-$country | jq -r .$1
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
yget(){
|
yget(){
|
||||||
date=$ydate
|
date=$ydate
|
||||||
get
|
get $1
|
||||||
}
|
}
|
||||||
result(){
|
result(){
|
||||||
echo "Total: $(get | jq -r '.cases')"
|
echo "Total: $(get cases)"
|
||||||
echo "Active: $(get | jq -r '.active')"
|
echo "Active: $(get active)"
|
||||||
echo "New: $(get | jq -r '.todayCases')"
|
echo "New: $(get todayCases)"
|
||||||
echo "Tests: $(get | jq -r '.tests')"
|
echo "Tests: $(get tests)"
|
||||||
show "Yesterday's stats:"
|
show "Yesterday's stats:"
|
||||||
echo "New: $(yget | jq -r '.todayCases')"
|
echo "New: $(yget todayCases)"
|
||||||
if [ $(get | jq -r '.todayCases') == "0" ]
|
if [ $(get 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') ]
|
elif [ $(get todayCases) == $(yget todayCases) ]
|
||||||
then
|
then
|
||||||
show "Seems like the stats are the same as yesterday."
|
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 "This could be normal but may mean that the data file is still yesterday's."
|
||||||
|
Reference in New Issue
Block a user