feat: schedule cron script to delete notifications older than 15 days
This commit is contained in:
@@ -17,7 +17,7 @@ const notifModel = mongoose.model(
|
||||
|
||||
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 } });
|
||||
|
||||
console.log(`Deleted ${result.deletedCount} notifications`);
|
||||
|
||||
@@ -15,4 +15,5 @@ CRON_DIR="$WORKDIR/cron"
|
||||
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/analytics.js"
|
||||
node --env-file=.env "$CRON_DIR/analytics.js"
|
||||
node --env-file=.env "$CRON_DIR/notificationCleanup.js"
|
||||
Reference in New Issue
Block a user