Resolve: "Update usage logging: Track average time per day each week"
Testing
In order to trigger a weekly submission, you need to edit the last submission date in the key value store in the indexeddb, unfortunately you can't do this from the inspector directly, but you can do it via snippets, at least in Chrome.
Snippet
You can add the following snippet via the Dev tools inspector (F12) by going to Sources > Snippets > + New Snippet. Then add the following code
const keyToEdit = 'usage-logging-last-submission'
const valueToSet = '2024-02-19'
// ###############################################
const dbName = 'rccDatabase'
const storeName = 'rccStorage'
const indexedName = 'rcc-key-value'
const version = 1
const connection = indexedDB.open(dbName, version)
connection.onsuccess = (e) => {
const database = e.target.result
const transaction = database.transaction(storeName, 'readwrite')
const objectStore = transaction.objectStore(storeName)
const getRequest = objectStore.get(indexedName)
getRequest.onsuccess = (getEvent) => {
const currentValue = JSON.parse(getEvent.target.result)
currentValue.forEach(kv => {
if (kv.key !== keyToEdit) return
kv.value = valueToSet
})
const putRequest = objectStore.put(JSON.stringify(currentValue), indexedName)
putRequest.onsuccess = () => {
console.log('Successfully updated')
}
}
}
The values at the start, about the horizontal line, are meant to be edited. Feel free to pick out a different date. The submission should be triggered if the last submission date is more than 7 days ago.
NB
The branch for this merge updates the key value store every minutes (as per the issue description), they key value store service stores all values in memory, and will overwrite whatever's in the actual DB, meaning that after executing this snippet, it'll soon get overwritten.
To get around this, you can either:
- Update the key value store via the snippet on another branch (e.g. main), then switch to this branch
- Quickly after running the snippet, refresh the page (e.g. via F5), note that if you do this, there's a small chance that the key value store will be updated before you have time to refresh, so you may need to try it twice.
Closes #1035 (closed)