New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ability to "cache" today's statistics #112
Comments
For anyone interested in this functionality, I've developed a script to do this: (change the top variables to your liking and setup) #!/bin/sh
maxTime=14400 # 14400 seconds = 4 hours; change this to your desired value
dateFormat="%Hh%Mm%Ss" # Format string to format the remaining time before updating, parsed by `date`
tempFile=/tmp/covidStatus # Path for the locally cached statistics
command="corona-cli portugal -m" # How you run the `corona-cli` command
if [ ! -f $tempFile ]; then
echo "COVID-19 Statistics: (no cached results; updating...)"
$command > $tempFile
else
timeCreated=$(date --utc --reference=$tempFile +%s)
timeNow=$(date --utc +%s)
delta=$(($timeNow-$timeCreated))
if [ $delta -gt $maxTime ]; then
echo "COVID-19 Statistics: (cached results too old; updating...)"
$command > $tempFile
else
echo "COVID-19 Statistics: (cached results; will update again in $(date --utc --date="@$(($maxTime-$delta))" +$dateFormat))"
fi
fi It would still be cool if this was properly implemented in the program, but for now, it does the job 😛 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is a very interesting project, especially for displaying everyday statistics on terminal initialization by adding it to
.bashrc
.However, the program always fetches the data online; thus it always takes some time to load. It would be cool if the program only fetched the current day's statistics and cache them locally: this way, any subsequent calls would run considerably faster (and as far as I know, most countries only update their statistics daily anyway).
The text was updated successfully, but these errors were encountered: