feat: schedule cron script to delete notifications older than 15 days

This commit is contained in:
2025-09-10 13:35:21 +05:30
parent b0863d1586
commit fc7e230fbb
2 changed files with 3 additions and 2 deletions

View File

@@ -17,7 +17,7 @@ const notifModel = mongoose.model(
await mongoose.connect(process.env.DB_URI); await mongoose.connect(process.env.DB_URI);
const fifthDay = new Date(Date.now() - 3600 * 24 * 5 * 1000); const fifthDay = new Date(Date.now() - 3600 * 24 * 15 * 1000);
const result = await notifModel.deleteMany({ createdAt: { $lt: fifthDay } }); const result = await notifModel.deleteMany({ createdAt: { $lt: fifthDay } });
console.log(`Deleted ${result.deletedCount} notifications`); console.log(`Deleted ${result.deletedCount} notifications`);

View File

@@ -16,3 +16,4 @@ cd "$WORKDIR" || { echo "Failed to change directory to $WORKDIR"; exit 1; }
node --env-file=.env "$CRON_DIR/configUpdate.js" node --env-file=.env "$CRON_DIR/configUpdate.js"
node --env-file=.env "$CRON_DIR/analytics.js" node --env-file=.env "$CRON_DIR/analytics.js"
node --env-file=.env "$CRON_DIR/notificationCleanup.js"