Skip to content

Commit

Permalink
refactor: increased delete log delay time
Browse files Browse the repository at this point in the history
  • Loading branch information
mrrishimeena committed Jun 25, 2024
1 parent 60dcb75 commit f1c7c81
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,15 @@ class ErrsoleSQLite extends EventEmitter {
let logsTTL = logsTTLDefault;
const configResult = await this.getConfig('logsTTL');
if (configResult && configResult.item && configResult.item.value) {
logsTTL = parseInt(configResult.item.value, 10) * 24 * 60 * 60 * 1000;
logsTTL = parseInt(configResult.item.value, 10);
}
const expirationTime = new Date(Date.now() - logsTTL);

let deletedRowCount;
do {
const result = await new Promise((resolve, reject) => {
this.db.run(
'DELETE FROM errsoleLogs WHERE timestamp < ?',
'DELETE FROM errsole_logs WHERE timestamp < ?',
[expirationTime],
function (err) {
if (err) {
Expand All @@ -323,7 +323,7 @@ class ErrsoleSQLite extends EventEmitter {
);
});
deletedRowCount = result;
await new Promise(resolve => setTimeout(resolve, 1000));
await new Promise(resolve => setTimeout(resolve, 10000));
} while (deletedRowCount > 0);
} catch (err) {
console.error(err);
Expand Down

0 comments on commit f1c7c81

Please sign in to comment.