mirror of
https://git.sr.ht/~cadence/bibliogram
synced 2026-03-01 18:31:35 +00:00
Ability to store request history in database
This commit is contained in:
parent
a6e7252566
commit
5a3eac338a
3 changed files with 20 additions and 2 deletions
|
|
@ -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() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue