fix: Prisma where clause conflict causing old non-terminal tasks to bypass dueDate cutoff

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.
This commit is contained in:
lorentz 2026-04-08 18:38:07 +00:00
parent 848881bbd8
commit f81817c0f6
3 changed files with 29 additions and 17 deletions

1
ondeck/.gitignore vendored
View file

@ -41,3 +41,4 @@ yarn-error.log*
next-env.d.ts
/src/generated/prisma
*.sql

View file

@ -22,17 +22,21 @@ export default async function TasksPage() {
const activeTaskWhere: Prisma.TaskWhereInput = {
assignments: { some: { userId } },
// Exclude tasks on dead policies
AND: [
// Exclude 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: [
{
OR: [
{ dueDate: { gte: cutoff } },

View file

@ -29,14 +29,21 @@ export async function GET(request: NextRequest) {
const showArchived = searchParams.get('archived') === 'true'
if (!showArchived) {
where.NOT = {
where.AND = [
// Exclude dead policies
{
NOT: {
policy: { status: { in: ['Cancelled', 'Expired', 'Non-Renewed', 'Rewritten', 'Not taken'] } },
}
where.OR = [
},
},
// Exclude tasks on expired renewal groups
{
OR: [
{ policyGroupId: null },
{ policyGroup: { renewalDate: { gte: cutoff } } },
]
where.AND = [
],
},
// Exclude old non-terminal tasks
{
OR: [
{ dueDate: { gte: cutoff } },