mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2025-12-18 03:58:49 +00:00
Ability to store request history in database
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
const constants = require("../constants")
|
||||
const db = require("../db")
|
||||
|
||||
class RequestHistory {
|
||||
/**
|
||||
* @param {string[]} tracked list of things that can be tracked
|
||||
@@ -23,6 +26,9 @@ class RequestHistory {
|
||||
const entry = this.store.get(key)
|
||||
entry.lastRequestAt = Date.now()
|
||||
entry.lastRequestSuccessful = success
|
||||
if (constants.caching.db_request_history) {
|
||||
db.prepare("INSERT INTO RequestHistory (type, success, timestamp) VALUES (?, ?, ?)").run(key, +entry.lastRequestSuccessful, entry.lastRequestAt)
|
||||
}
|
||||
}
|
||||
|
||||
export() {
|
||||
|
||||
Reference in New Issue
Block a user