unifying surrogate keys for event log and options, fixes #103

This commit is contained in:
azivner
2018-05-26 23:25:09 -04:00
parent a30734f1bc
commit cab54a458f
6 changed files with 41 additions and 21 deletions

View File

@@ -3,19 +3,9 @@
const sql = require('../../services/sql');
async function getEventLog() {
await deleteOld();
return await sql.getRows("SELECT * FROM event_log ORDER BY dateCreated DESC");
}
async function deleteOld() {
const cutoffId = await sql.getValue("SELECT id FROM event_log ORDER BY id DESC LIMIT 1000, 1");
if (cutoffId) {
await sql.execute("DELETE FROM event_log WHERE id < ?", [cutoffId]);
}
}
module.exports = {
getEventLog
};