-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
⏰ Add cron job to delete expired pro entires (#yoginth/eng-101-add-cr…
…on-job-to-delete-expired-pro-entires) Summary: Added a cron job to delete expired pro entries. Highlights: • Created `cleanExpiredPro.ts` to delete expired pro entries using Prisma. • Integrated `cleanExpiredPro` into the cron job scheduler in `index.ts` to run every 5 minutes. Read more: https://pierre.co/hey/hey/yoginth/eng-101-add-cron-job-to-delete-expired-pro-entires
- Loading branch information
Yoginth
authored and
Pierre
committed
Sep 27, 2024
1 parent
7364e36
commit c6e04e2
Showing
2 changed files
with
22 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import prisma from "@hey/db/prisma/db/client"; | ||
import logger from "@hey/helpers/logger"; | ||
|
||
const cleanExpiredPro = async () => { | ||
try { | ||
await prisma.pro.deleteMany({ | ||
where: { expiresAt: { lt: new Date() } } | ||
}); | ||
|
||
logger.info("[Cron] cleanExpiredPro - Cleaned up expired pro"); | ||
} catch (error) { | ||
logger.error("[Cron] cleanExpiredPro - Error cleaning expired pro", error); | ||
} | ||
}; | ||
|
||
export default cleanExpiredPro; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters