feat: prevent duplicate award pool notifications
All checks were successful
Build and Push Docker Image / build (push) Successful in 10m1s
All checks were successful
Build and Push Docker Image / build (push) Successful in 10m1s
Add notifiedAt field to AwardEligibility. notifyEligibleProjects now skips already-notified entries and stamps notifiedAt after sending, so re-clicking "Notify Pool" only emails newly added projects. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
-- AlterTable
|
||||
ALTER TABLE "AwardEligibility" ADD COLUMN "notifiedAt" TIMESTAMP(3);
|
||||
@@ -1622,6 +1622,9 @@ model AwardEligibility {
|
||||
confirmedAt DateTime?
|
||||
confirmedBy String?
|
||||
|
||||
// Pool notification tracking
|
||||
notifiedAt DateTime?
|
||||
|
||||
createdAt DateTime @default(now())
|
||||
updatedAt DateTime @updatedAt
|
||||
|
||||
|
||||
@@ -1269,9 +1269,9 @@ export const specialAwardRouter = router({
|
||||
select: { id: true, name: true, description: true, status: true },
|
||||
})
|
||||
|
||||
// Get eligible projects with submitter + team members
|
||||
// Get eligible projects that haven't been notified yet
|
||||
const eligibilities = await ctx.prisma.awardEligibility.findMany({
|
||||
where: { awardId: input.awardId, eligible: true },
|
||||
where: { awardId: input.awardId, eligible: true, notifiedAt: null },
|
||||
select: {
|
||||
id: true,
|
||||
projectId: true,
|
||||
@@ -1365,6 +1365,15 @@ export const specialAwardRouter = router({
|
||||
}
|
||||
}
|
||||
|
||||
// Stamp notifiedAt on all processed eligibilities to prevent re-notification
|
||||
const notifiedIds = eligibilities.map((e) => e.id)
|
||||
if (notifiedIds.length > 0) {
|
||||
await ctx.prisma.awardEligibility.updateMany({
|
||||
where: { id: { in: notifiedIds } },
|
||||
data: { notifiedAt: new Date() },
|
||||
})
|
||||
}
|
||||
|
||||
await logAudit({
|
||||
prisma: ctx.prisma,
|
||||
userId: ctx.user.id,
|
||||
|
||||
Reference in New Issue
Block a user