- One Cache for all Widget Sizes
- allow to perform a force update
This commit is contained in:
Benny 2021-01-03 14:07:47 +01:00
parent 59a480baef
commit d43b1d212c
2 changed files with 12 additions and 5 deletions

View file

@ -9,7 +9,7 @@
This widget displays the number of Covid 19 vaccinations. In the small and medium widet, the total number for all states is displayed by default. By entering the state name in the widget parameters, you can switch to the number for the state in the small widget. In the medium widget, by entering the state name, the numbers of the state are displayed next to those of the whole Germany.
The large widget shows all 16 states and the total.
_The widget is using a cache for 6 hours to protect the server from too much load. Since the data is updated by the RKI itself only once a day, this should be sufficient._
_The widget is using a cache for 4 hours to protect the server from too much load. Since the data is updated by the RKI itself only once a day, this should be sufficient. If you like to perform a force update, you can use this URL: `scriptable:///run/number-of-covild-19-vaccinations?forceUpdate=true` or click [here](https://open.scriptable.app/run/number-of-covild-19-vaccinations?forceUpdate=true)_
[[Download]](https://raw.githubusercontent.com/ThisIsBenny/iOS-Widgets/main/number-of-covild-19-vaccinations/number-of-covild-19-vaccinations.js)

View file

@ -3,9 +3,12 @@
// icon-color: red; icon-glyph: syringe;
/**************
Version 1.1.0
Version 1.1.1
Changelog:
v1.1.1
- Cache path changed
- Allow force Update of the data
v1.1.0
- Cache TTL changed to 4 hours
- Show total numbers in large widget
@ -24,7 +27,7 @@ Changelog:
////////////////////////////////////////////////////////////////////////////////
// How many minutes should the cache be valid
const cacheMinutes = 4 * 60
let cacheMinutes = 4 * 60
// Set to true to show total numbers in the large widget
const showTotalInLargeWidget = false
@ -34,7 +37,7 @@ const showTotalInLargeWidget = false
////////////////////////////////////////////////////////////////////////////////
const debug = false
config.widgetFamily = config.widgetFamily || 'large'
config.widgetFamily = config.widgetFamily || 'medium'
////////////////////////////////////////////////////////////////////////////////
////////////////////////// System Settings /////////////////////
@ -71,6 +74,10 @@ const thresholds = {
green: 79
}
if (args.queryParameters.forceUpdate) {
cacheMinutes = 0
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
@ -181,7 +188,7 @@ var today = new Date()
const files = FileManager.local()
// Set up cache
const cachePath = files.joinPath(files.cacheDirectory(), "widget-vaccination-" + config.widgetFamily)
const cachePath = files.joinPath(files.cacheDirectory(), "widget-vaccination")
const cacheExists = files.fileExists(cachePath)
const cacheDate = cacheExists ? files.modificationDate(cachePath) : 0