Drop old unprocessed envelopes

This commit is contained in:
Fedor Indutny 2021-12-14 02:25:44 +01:00 committed by GitHub
parent 465b387a13
commit 71ca3c0764
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 31 additions and 7 deletions

View file

@ -3028,6 +3028,19 @@ async function getUnprocessedCount(): Promise<number> {
async function getAllUnprocessed(): Promise<Array<UnprocessedType>> {
const db = getInstance();
const { changes: deletedCount } = db
.prepare<Query>('DELETE FROM unprocessed WHERE timestamp < $monthAgo')
.run({
monthAgo: Date.now() - durations.MONTH,
});
if (deletedCount !== 0) {
logger.warn(
`getAllUnprocessed: deleting ${deletedCount} old unprocessed envelopes`
);
}
const rows = db
.prepare<EmptyQuery>(
`