feat: clear expired notification date
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 7s
All checks were successful
Spell Check / Spell Check with Typos (push) Successful in 7s
This commit is contained in:
parent
3803c3378a
commit
c7fae98516
1 changed files with 13 additions and 0 deletions
|
|
@ -1,3 +1,4 @@
|
||||||
|
import dayjs from "dayjs";
|
||||||
import { CronJob } from "cron";
|
import { CronJob } from "cron";
|
||||||
|
|
||||||
import prisma from "../db";
|
import prisma from "../db";
|
||||||
|
|
@ -25,6 +26,18 @@ const jobs = [
|
||||||
.catch((e) => console.error("[ERR]: Update expired quotation status, FAILED.", e));
|
.catch((e) => console.error("[ERR]: Update expired quotation status, FAILED.", e));
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
CronJob.from({
|
||||||
|
cronTime: "0 0 0 * * *",
|
||||||
|
runOnInit: true,
|
||||||
|
onTick: async () => {
|
||||||
|
await prisma.notification
|
||||||
|
.deleteMany({
|
||||||
|
where: { createdAt: { lte: dayjs().subtract(1, "month").toDate() } },
|
||||||
|
})
|
||||||
|
.then(() => console.log("[INFO]: Delete expired notification, OK."))
|
||||||
|
.catch((e) => console.error("[ERR]: Update expired quotation status, FAILED.", e));
|
||||||
|
},
|
||||||
|
}),
|
||||||
];
|
];
|
||||||
|
|
||||||
export function initSchedule() {
|
export function initSchedule() {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue