From f81817c0f6f2a3388656822277c6d1d0d169a9b9 Mon Sep 17 00:00:00 2001 From: lorentz Date: Wed, 8 Apr 2026 18:38:07 +0000 Subject: [PATCH] fix: Prisma where clause conflict causing old non-terminal tasks to bypass dueDate cutoff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Top-level OR and AND keys on the same where object conflicted — consolidated all suppression conditions into a single AND array in both the SSR page query and the /api/tasks route. --- ondeck/.gitignore | 1 + ondeck/src/app/(dashboard)/tasks/page.tsx | 24 +++++++++++++---------- ondeck/src/app/api/tasks/route.ts | 21 +++++++++++++------- 3 files changed, 29 insertions(+), 17 deletions(-) diff --git a/ondeck/.gitignore b/ondeck/.gitignore index f390d12..851cd3c 100644 --- a/ondeck/.gitignore +++ b/ondeck/.gitignore @@ -41,3 +41,4 @@ yarn-error.log* next-env.d.ts /src/generated/prisma +*.sql diff --git a/ondeck/src/app/(dashboard)/tasks/page.tsx b/ondeck/src/app/(dashboard)/tasks/page.tsx index 375f75d..fdab7a3 100644 --- a/ondeck/src/app/(dashboard)/tasks/page.tsx +++ b/ondeck/src/app/(dashboard)/tasks/page.tsx @@ -22,17 +22,21 @@ export default async function TasksPage() { const activeTaskWhere: Prisma.TaskWhereInput = { assignments: { some: { userId } }, - // Exclude tasks on dead policies - NOT: { - policy: { status: { in: ['Cancelled', 'Expired', 'Non-Renewed', 'Rewritten', 'Not taken'] } }, - } as Prisma.TaskWhereInput, - // Exclude tasks on expired renewal groups - OR: [ - { policyGroupId: null }, - { policyGroup: { renewalDate: { gte: cutoff } } }, - ], - // Only show recent or terminal tasks AND: [ + // Exclude dead policies + { + NOT: { + policy: { status: { in: ['Cancelled', 'Expired', 'Non-Renewed', 'Rewritten', 'Not taken'] } }, + }, + }, + // Exclude tasks on expired renewal groups + { + OR: [ + { policyGroupId: null }, + { policyGroup: { renewalDate: { gte: cutoff } } }, + ], + }, + // Only show recent or terminal tasks { OR: [ { dueDate: { gte: cutoff } }, diff --git a/ondeck/src/app/api/tasks/route.ts b/ondeck/src/app/api/tasks/route.ts index 1c2e2fb..d3dce67 100644 --- a/ondeck/src/app/api/tasks/route.ts +++ b/ondeck/src/app/api/tasks/route.ts @@ -29,14 +29,21 @@ export async function GET(request: NextRequest) { const showArchived = searchParams.get('archived') === 'true' if (!showArchived) { - where.NOT = { - policy: { status: { in: ['Cancelled', 'Expired', 'Non-Renewed', 'Rewritten', 'Not taken'] } }, - } - where.OR = [ - { policyGroupId: null }, - { policyGroup: { renewalDate: { gte: cutoff } } }, - ] where.AND = [ + // Exclude dead policies + { + NOT: { + policy: { status: { in: ['Cancelled', 'Expired', 'Non-Renewed', 'Rewritten', 'Not taken'] } }, + }, + }, + // Exclude tasks on expired renewal groups + { + OR: [ + { policyGroupId: null }, + { policyGroup: { renewalDate: { gte: cutoff } } }, + ], + }, + // Exclude old non-terminal tasks { OR: [ { dueDate: { gte: cutoff } },