Wire prior archive cutoff through API

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-17 16:52:20 +03:30
co-authored by Cursor
parent 02841a5b8c
commit 79ba146118
11 changed files with 74 additions and 34 deletions
+4 -10
View File
@@ -29,7 +29,6 @@ import { decimalToBase, loadOrgRates, toBaseAmount } from '../common/currency';
import {
activityPriorWhere,
dealPriorWhere,
personPriorWhere,
} from '../common/prior-archive';
import {
addJalaliMonths,
@@ -62,9 +61,8 @@ export class ReportsService {
const prevStart = new Date(prevEnd.getTime() - durationMs);
const now = new Date();
const peoplePrior = personPriorWhere(actor.priorLens);
const dealsPrior = dealPriorWhere(actor.priorLens, now);
const activitiesPrior = activityPriorWhere(actor.priorLens, now, actor.priorCutoff);
const dealsPrior = dealPriorWhere(actor.priorLens, actor.priorCutoff);
const activitiesPrior = activityPriorWhere(actor.priorLens, actor.priorCutoff);
const { jy, jm } = dateToJalali(now);
const sixAgo = addJalaliMonths(jy, jm, -5);
const sixMonthStart = startOfJalaliMonth(sixAgo.jy, sixAgo.jm);
@@ -160,7 +158,6 @@ export class ReportsService {
where: {
organizationId: orgId,
...personScope,
...peoplePrior,
},
select: { mood: true, createdAt: true },
}),
@@ -1551,9 +1548,8 @@ export class ReportsService {
const yesterdayEnd = endOfDay(yesterday);
const weekAgo = new Date(now);
weekAgo.setDate(weekAgo.getDate() - 7);
const peoplePrior = personPriorWhere(actor.priorLens);
const dealsPrior = dealPriorWhere(actor.priorLens, now);
const activitiesPrior = activityPriorWhere(actor.priorLens, now, actor.priorCutoff);
const dealsPrior = dealPriorWhere(actor.priorLens, actor.priorCutoff);
const activitiesPrior = activityPriorWhere(actor.priorLens, actor.priorCutoff);
const [
wonDeals,
@@ -1618,7 +1614,6 @@ export class ReportsService {
where: {
organizationId: orgId,
...personScope,
...peoplePrior,
createdAt: { gte: curMonthStart, lte: curMonthEnd },
},
}),
@@ -1626,7 +1621,6 @@ export class ReportsService {
where: {
organizationId: orgId,
...personScope,
...peoplePrior,
createdAt: { gte: prevMonthStart, lte: prevMonthEnd },
},
}),