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:
parent
848881bbd8
commit
f81817c0f6
3 changed files with 29 additions and 17 deletions
1
ondeck/.gitignore
vendored
1
ondeck/.gitignore
vendored
|
|
@ -41,3 +41,4 @@ yarn-error.log*
|
|||
next-env.d.ts
|
||||
|
||||
/src/generated/prisma
|
||||
*.sql
|
||||
|
|
|
|||
|
|
@ -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 } },
|
||||
|
|
|
|||
|
|
@ -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 } },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue