X-Git-Url: http://git.squeep.com/?p=squeep-indie-auther;a=blobdiff_plain;f=src%2Fdb%2Fsqlite%2Findex.js;fp=src%2Fdb%2Fsqlite%2Findex.js;h=97027be662733e4cac566a7eccb284bd9256aad0;hp=453dbf8eada1b9d39d79ac2c47a6e27738c59b40;hb=e8dccf76ec2776f07eddd1ce2f1c4fc150a6f790;hpb=4a8977142d1f54e168f6cc7b229133863fcf0dba diff --git a/src/db/sqlite/index.js b/src/db/sqlite/index.js index 453dbf8..97027be 100644 --- a/src/db/sqlite/index.js +++ b/src/db/sqlite/index.js @@ -267,6 +267,11 @@ class DatabaseSQLite extends Database { } + static _almanacErrorThrow() { + throw new DBErrors.UnexpectedResult('did not update almanac'); + } + + almanacGetAll(dbCtx) { // eslint-disable-line no-unused-vars const _scope = _fileScope('almanacGetAll'); this.logger.debug(_scope, 'called'); @@ -289,7 +294,7 @@ class DatabaseSQLite extends Database { const epoch = common.dateToEpoch(date); const result = this.statement.almanacUpsert.run({ event, epoch }); if (result.changes != 1) { - throw new DBErrors.UnexpectedResult('did not upsert almanac event'); + this.constructor._almanacErrorThrow(); } } catch (e) { this.logger.error(_scope, 'failed', { error: e, event, date }); @@ -580,7 +585,7 @@ class DatabaseSQLite extends Database { // Update the last cleanup time const result = this.statement.almanacUpsert.run({ event: almanacEvent, epoch: nowEpoch }); if (result.changes != 1) { - throw new DBErrors.UnexpectedResult('did not update almanac'); + this.constructor._almanacErrorThrow(); } this.logger.debug(_scope, 'finished', { scopesRemoved, atLeastMsSinceLast }); @@ -658,7 +663,7 @@ class DatabaseSQLite extends Database { // Update the last cleanup time const result = this.statement.almanacUpsert.run({ event: almanacEvent, epoch: nowEpoch }); if (result.changes != 1) { - throw new DBErrors.UnexpectedResult('did not update almanac'); + this.constructor._almanacErrorThrow(); } this.logger.debug(_scope, 'finished', { tokensRemoved, codeLifespanSeconds, atLeastMsSinceLast }); @@ -786,7 +791,7 @@ class DatabaseSQLite extends Database { const epoch = common.dateToEpoch(); const almanacResult = this.statement.almanacUpsert.run({ event: almanacEvent, epoch }); if (almanacResult.changes != 1) { - throw new DBErrors.UnexpectedResult('did not update almanac'); + this.constructor._almanacErrorThrow(); } } catch (e) {