You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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` commandif [ !-f$tempFile ];thenecho"COVID-19 Statistics: (no cached results; updating...)"$command>$tempFileelse
timeCreated=$(date --utc --reference=$tempFile +%s)
timeNow=$(date --utc +%s)
delta=$(($timeNow-$timeCreated))if [ $delta-gt$maxTime ];thenecho"COVID-19 Statistics: (cached results too old; updating...)"$command>$tempFileelseecho"COVID-19 Statistics: (cached results; will update again in $(date --utc --date="@$(($maxTime-$delta))" +$dateFormat))"fifi
It would still be cool if this was properly implemented in the program, but for now, it does the job 😛
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: