1
0
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:
Cadence Ember
2020-04-17 01:14:27 +12:00
parent a6e7252566
commit 5a3eac338a
3 changed files with 20 additions and 2 deletions

View File

@@ -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() {