fix: keep imported follow-ups out of current work

They stayed on the board when a non-prior deal was attached, even though the person was prior.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-15 12:34:40 +03:30
co-authored by Cursor
parent 6bc5e1bec7
commit 6bff9d2888
9 changed files with 102 additions and 16 deletions
@@ -38,7 +38,7 @@ import {
type DtoContext = { stages?: StageDefaults; types?: SystemTypes };
type ActivityActor = Pick<Actor, 'userId' | 'role' | 'priorLens'>;
type ActivityActor = Pick<Actor, 'userId' | 'role' | 'priorLens' | 'priorCutoff'>;
/** stageId = شناسهٔ مرحله یا 'all'؛ وقتی ست باشد فیلتر زمانی وضعیت را تحمیل نمی‌کند (جز عقب‌افتاده) */
type StageScope = { stageId: string };
@@ -119,7 +119,7 @@ export class ActivitiesService {
): Promise<ActivitySummaryDto> {
const { start, end } = dayBounds();
const scope = activityAccessWhere(actor);
const prior = activityPriorWhere(actor.priorLens);
const prior = activityPriorWhere(actor.priorLens, new Date(), actor.priorCutoff);
const [todayCount, overdueCount] = await Promise.all([
this.prisma.activity.count({
where: {
@@ -700,7 +700,9 @@ export class ActivitiesService {
]);
if (search) andParts.push(search);
const onRecord = Boolean(entity?.personId || entity?.companyId || entity?.dealId);
if (!onRecord) andParts.push(activityPriorWhere(actor.priorLens));
if (!onRecord) {
andParts.push(activityPriorWhere(actor.priorLens, new Date(), actor.priorCutoff));
}
const base: Prisma.ActivityWhereInput = {
organizationId,
AND: andParts,