From 34dbc57e756ffb95e31f9efbd75ee5d58a73a2d4 Mon Sep 17 00:00:00 2001 From: Michael De Roover Date: Wed, 6 May 2020 20:34:58 +0200 Subject: [PATCH] Optimize get --- cv | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/cv b/cv index c3cc813..120f479 100755 --- a/cv +++ b/cv @@ -26,29 +26,29 @@ country=$1 get(){ if [ -f $data/$date-$country ] then - cat $data/$date-$country + cat $data/$date-$country | jq -r .$1 else curl -sL corona.lmao.ninja/v2/$endpoint > $data/$date-$country - cat $data/$date-$country + cat $data/$date-$country | jq -r .$1 fi } yget(){ date=$ydate - get + get $1 } result(){ - echo "Total: $(get | jq -r '.cases')" - echo "Active: $(get | jq -r '.active')" - echo "New: $(get | jq -r '.todayCases')" - echo "Tests: $(get | jq -r '.tests')" + echo "Total: $(get cases)" + echo "Active: $(get active)" + echo "New: $(get todayCases)" + echo "Tests: $(get tests)" show "Yesterday's stats:" - echo "New: $(yget | jq -r '.todayCases')" - if [ $(get | jq -r '.todayCases') == "0" ] + echo "New: $(yget todayCases)" + if [ $(get todayCases) == "0" ] then show "Seems like the cases today are not yet updated." show "The data file will be removed. Please query again later." ex "rm $data/$date-$country" - elif [ $(get | jq -r '.todayCases') == $(yget | jq -r '.todayCases') ] + elif [ $(get todayCases) == $(yget 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."