Fix prior archive filter collisions
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -12,7 +12,7 @@
|
|||||||
"prisma:seed": "tsx prisma/seed.ts",
|
"prisma:seed": "tsx prisma/seed.ts",
|
||||||
"lint": "echo \"api lint placeholder\"",
|
"lint": "echo \"api lint placeholder\"",
|
||||||
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p test/tsconfig.json",
|
"typecheck": "tsc --noEmit -p tsconfig.json && tsc --noEmit -p test/tsconfig.json",
|
||||||
"test": "tsx --test test/tahesab-methods.test.ts test/dates.test.ts test/birthdays.test.ts test/message-automation.test.ts test/record-scope.test.ts test/gamification-engine.test.ts test/automation-branches.test.ts test/pipeline-merge.test.ts test/ask-count.test.ts test/prior-archive.test.ts test/organizations.test.ts"
|
"test": "tsx --test test/tahesab-methods.test.ts test/dates.test.ts test/birthdays.test.ts test/message-automation.test.ts test/record-scope.test.ts test/gamification-engine.test.ts test/automation-branches.test.ts test/pipeline-merge.test.ts test/ask-count.test.ts test/prior-archive.test.ts test/organizations.test.ts test/promote-from-prior.test.ts"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@mento/shared": "*",
|
"@mento/shared": "*",
|
||||||
|
|||||||
@@ -399,10 +399,14 @@ Rules:
|
|||||||
activity: () =>
|
activity: () =>
|
||||||
this.prisma.activity.count({
|
this.prisma.activity.count({
|
||||||
where: {
|
where: {
|
||||||
|
AND: [
|
||||||
|
{
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
...assigneeWhere(actor),
|
|
||||||
...created,
|
...created,
|
||||||
...activityPriorWhere(actor.priorLens, actor.priorCutoff),
|
},
|
||||||
|
assigneeWhere(actor),
|
||||||
|
activityPriorWhere(actor.priorLens, actor.priorCutoff),
|
||||||
|
],
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
ticket: () =>
|
ticket: () =>
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import {
|
|||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { JwtService } from '@nestjs/jwt';
|
import { JwtService } from '@nestjs/jwt';
|
||||||
import * as bcrypt from 'bcryptjs';
|
import * as bcrypt from 'bcryptjs';
|
||||||
import type {} from 'multer';
|
|
||||||
import * as path from 'path';
|
import * as path from 'path';
|
||||||
import type {
|
import type {
|
||||||
AuthUserDto,
|
AuthUserDto,
|
||||||
|
|||||||
@@ -113,8 +113,10 @@ export class DealsExcelService {
|
|||||||
this.prisma.deal.findMany({
|
this.prisma.deal.findMany({
|
||||||
where: {
|
where: {
|
||||||
organizationId: actor.organizationId,
|
organizationId: actor.organizationId,
|
||||||
...dealAccessWhere(actor),
|
AND: [
|
||||||
...dealPriorWhere(actor.priorLens, actor.priorCutoff),
|
dealAccessWhere(actor),
|
||||||
|
dealPriorWhere(actor.priorLens, actor.priorCutoff),
|
||||||
|
],
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
person: {
|
person: {
|
||||||
|
|||||||
@@ -328,8 +328,10 @@ export class PipelinesService {
|
|||||||
where: {
|
where: {
|
||||||
organizationId,
|
organizationId,
|
||||||
pipelineId: resolved.id,
|
pipelineId: resolved.id,
|
||||||
...(actor ? dealAccessWhere(actor) : {}),
|
AND: [
|
||||||
...(includePrior ? {} : dealPriorWhere(actor?.priorLens, actor?.priorCutoff)),
|
...(actor ? [dealAccessWhere(actor)] : []),
|
||||||
|
...(includePrior ? [] : [dealPriorWhere(actor?.priorLens, actor?.priorCutoff)]),
|
||||||
|
],
|
||||||
},
|
},
|
||||||
include: {
|
include: {
|
||||||
person: { select: { id: true, firstName: true, lastName: true } },
|
person: { select: { id: true, firstName: true, lastName: true } },
|
||||||
|
|||||||
@@ -127,11 +127,15 @@ export class ReportsService {
|
|||||||
}),
|
}),
|
||||||
this.prisma.activity.findMany({
|
this.prisma.activity.findMany({
|
||||||
where: {
|
where: {
|
||||||
|
AND: [
|
||||||
|
{
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
...activityScope,
|
|
||||||
...activitiesPrior,
|
|
||||||
createdAt: { gte: prevStart, lte: end },
|
createdAt: { gte: prevStart, lte: end },
|
||||||
},
|
},
|
||||||
|
activityScope,
|
||||||
|
activitiesPrior,
|
||||||
|
],
|
||||||
|
},
|
||||||
select: {
|
select: {
|
||||||
id: true,
|
id: true,
|
||||||
type: true,
|
type: true,
|
||||||
@@ -1565,12 +1569,16 @@ export class ReportsService {
|
|||||||
] = await Promise.all([
|
] = await Promise.all([
|
||||||
this.prisma.deal.findMany({
|
this.prisma.deal.findMany({
|
||||||
where: {
|
where: {
|
||||||
|
AND: [
|
||||||
|
{
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
status: 'won',
|
status: 'won',
|
||||||
...dealScope,
|
|
||||||
...dealsPrior,
|
|
||||||
updatedAt: { gte: addMonthsStart(now, -5) },
|
updatedAt: { gte: addMonthsStart(now, -5) },
|
||||||
},
|
},
|
||||||
|
dealScope,
|
||||||
|
dealsPrior,
|
||||||
|
],
|
||||||
|
},
|
||||||
select: {
|
select: {
|
||||||
amount: true,
|
amount: true,
|
||||||
currency: true,
|
currency: true,
|
||||||
@@ -1583,7 +1591,13 @@ export class ReportsService {
|
|||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
this.prisma.deal.count({
|
this.prisma.deal.count({
|
||||||
where: { organizationId: orgId, status: 'open', ...dealScope, ...dealsPrior },
|
where: {
|
||||||
|
AND: [
|
||||||
|
{ organizationId: orgId, status: 'open' },
|
||||||
|
dealScope,
|
||||||
|
dealsPrior,
|
||||||
|
],
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
this.prisma.deal.findMany({
|
this.prisma.deal.findMany({
|
||||||
where: {
|
where: {
|
||||||
@@ -1626,29 +1640,41 @@ export class ReportsService {
|
|||||||
}),
|
}),
|
||||||
this.prisma.activity.count({
|
this.prisma.activity.count({
|
||||||
where: {
|
where: {
|
||||||
|
AND: [
|
||||||
|
{
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
...activityScope,
|
|
||||||
...activitiesPrior,
|
|
||||||
status: 'open',
|
status: 'open',
|
||||||
dueAt: { gte: todayStart, lte: todayEnd },
|
dueAt: { gte: todayStart, lte: todayEnd },
|
||||||
},
|
},
|
||||||
|
activityScope,
|
||||||
|
activitiesPrior,
|
||||||
|
],
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
this.prisma.activity.count({
|
this.prisma.activity.count({
|
||||||
where: {
|
where: {
|
||||||
|
AND: [
|
||||||
|
{
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
...activityScope,
|
|
||||||
...activitiesPrior,
|
|
||||||
dueAt: { gte: yesterdayStart, lte: yesterdayEnd },
|
dueAt: { gte: yesterdayStart, lte: yesterdayEnd },
|
||||||
},
|
},
|
||||||
|
activityScope,
|
||||||
|
activitiesPrior,
|
||||||
|
],
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
this.prisma.deal.count({
|
this.prisma.deal.count({
|
||||||
where: {
|
where: {
|
||||||
|
AND: [
|
||||||
|
{
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
status: 'open',
|
status: 'open',
|
||||||
...dealScope,
|
|
||||||
...dealsPrior,
|
|
||||||
updatedAt: { lte: weekAgo },
|
updatedAt: { lte: weekAgo },
|
||||||
},
|
},
|
||||||
|
dealScope,
|
||||||
|
dealsPrior,
|
||||||
|
],
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
this.prisma.salesGoal.findMany({
|
this.prisma.salesGoal.findMany({
|
||||||
where: {
|
where: {
|
||||||
@@ -1660,12 +1686,16 @@ export class ReportsService {
|
|||||||
}),
|
}),
|
||||||
this.prisma.activity.count({
|
this.prisma.activity.count({
|
||||||
where: {
|
where: {
|
||||||
|
AND: [
|
||||||
|
{
|
||||||
organizationId: orgId,
|
organizationId: orgId,
|
||||||
...activityScope,
|
|
||||||
...activitiesPrior,
|
|
||||||
status: 'open',
|
status: 'open',
|
||||||
dueAt: { lt: now },
|
dueAt: { lt: now },
|
||||||
},
|
},
|
||||||
|
activityScope,
|
||||||
|
activitiesPrior,
|
||||||
|
],
|
||||||
|
},
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user