Fix prior archive filter collisions
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -127,10 +127,14 @@ export class ReportsService {
|
||||
}),
|
||||
this.prisma.activity.findMany({
|
||||
where: {
|
||||
organizationId: orgId,
|
||||
...activityScope,
|
||||
...activitiesPrior,
|
||||
createdAt: { gte: prevStart, lte: end },
|
||||
AND: [
|
||||
{
|
||||
organizationId: orgId,
|
||||
createdAt: { gte: prevStart, lte: end },
|
||||
},
|
||||
activityScope,
|
||||
activitiesPrior,
|
||||
],
|
||||
},
|
||||
select: {
|
||||
id: true,
|
||||
@@ -1565,11 +1569,15 @@ export class ReportsService {
|
||||
] = await Promise.all([
|
||||
this.prisma.deal.findMany({
|
||||
where: {
|
||||
organizationId: orgId,
|
||||
status: 'won',
|
||||
...dealScope,
|
||||
...dealsPrior,
|
||||
updatedAt: { gte: addMonthsStart(now, -5) },
|
||||
AND: [
|
||||
{
|
||||
organizationId: orgId,
|
||||
status: 'won',
|
||||
updatedAt: { gte: addMonthsStart(now, -5) },
|
||||
},
|
||||
dealScope,
|
||||
dealsPrior,
|
||||
],
|
||||
},
|
||||
select: {
|
||||
amount: true,
|
||||
@@ -1583,7 +1591,13 @@ export class ReportsService {
|
||||
},
|
||||
}),
|
||||
this.prisma.deal.count({
|
||||
where: { organizationId: orgId, status: 'open', ...dealScope, ...dealsPrior },
|
||||
where: {
|
||||
AND: [
|
||||
{ organizationId: orgId, status: 'open' },
|
||||
dealScope,
|
||||
dealsPrior,
|
||||
],
|
||||
},
|
||||
}),
|
||||
this.prisma.deal.findMany({
|
||||
where: {
|
||||
@@ -1626,28 +1640,40 @@ export class ReportsService {
|
||||
}),
|
||||
this.prisma.activity.count({
|
||||
where: {
|
||||
organizationId: orgId,
|
||||
...activityScope,
|
||||
...activitiesPrior,
|
||||
status: 'open',
|
||||
dueAt: { gte: todayStart, lte: todayEnd },
|
||||
AND: [
|
||||
{
|
||||
organizationId: orgId,
|
||||
status: 'open',
|
||||
dueAt: { gte: todayStart, lte: todayEnd },
|
||||
},
|
||||
activityScope,
|
||||
activitiesPrior,
|
||||
],
|
||||
},
|
||||
}),
|
||||
this.prisma.activity.count({
|
||||
where: {
|
||||
organizationId: orgId,
|
||||
...activityScope,
|
||||
...activitiesPrior,
|
||||
dueAt: { gte: yesterdayStart, lte: yesterdayEnd },
|
||||
AND: [
|
||||
{
|
||||
organizationId: orgId,
|
||||
dueAt: { gte: yesterdayStart, lte: yesterdayEnd },
|
||||
},
|
||||
activityScope,
|
||||
activitiesPrior,
|
||||
],
|
||||
},
|
||||
}),
|
||||
this.prisma.deal.count({
|
||||
where: {
|
||||
organizationId: orgId,
|
||||
status: 'open',
|
||||
...dealScope,
|
||||
...dealsPrior,
|
||||
updatedAt: { lte: weekAgo },
|
||||
AND: [
|
||||
{
|
||||
organizationId: orgId,
|
||||
status: 'open',
|
||||
updatedAt: { lte: weekAgo },
|
||||
},
|
||||
dealScope,
|
||||
dealsPrior,
|
||||
],
|
||||
},
|
||||
}),
|
||||
this.prisma.salesGoal.findMany({
|
||||
@@ -1660,11 +1686,15 @@ export class ReportsService {
|
||||
}),
|
||||
this.prisma.activity.count({
|
||||
where: {
|
||||
organizationId: orgId,
|
||||
...activityScope,
|
||||
...activitiesPrior,
|
||||
status: 'open',
|
||||
dueAt: { lt: now },
|
||||
AND: [
|
||||
{
|
||||
organizationId: orgId,
|
||||
status: 'open',
|
||||
dueAt: { lt: now },
|
||||
},
|
||||
activityScope,
|
||||
activitiesPrior,
|
||||
],
|
||||
},
|
||||
}),
|
||||
]);
|
||||
|
||||
Reference in New Issue
Block a user