Skip to content

Commit

Permalink
fix(msgData): Changed delete interval to 24h
Browse files Browse the repository at this point in the history
  • Loading branch information
dev-737 committed Mar 6, 2023
1 parent e453044 commit 326635f
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Events/ready.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,19 @@ export default {
const db = getDb();
const messageData = db.messageData;

// set a property called "expired" to a document that is older than 4 hours.
// set a property called "expired" to a document that is older than 12 hours.
setInterval(async () => {
const older_than_four = new Date(Date.now() - 60 * 60 * 4000); // 4 hours before now
const older_than_four = new Date(Date.now() - 60 * 60 * 12_000); // 12 hours before now
await messageData.updateMany({
where: { timestamp: { lte: older_than_four.getTime() } },
data: { expired: true },
});
}, 60 * 60 * 4100);
}, 60 * 60 * 12_100);

// Delete all documents that have the property "expired" set to true.
// Delete all documents that has the property "expired" set to true.
setInterval(async () => {
await messageData?.deleteMany({ where: { expired: true } });
}, 60 * 60 * 12_000);
}, 60 * 60 * 24_000);

if (client.isReady()) {
const blacklistedServers = await db.blacklistedServers.findMany({ where: { expires: { isSet: true } } });
Expand Down

0 comments on commit 326635f

Please sign in to comment.