fix: enforce drainage uniqueness and carrier-specific reporting
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { BadRequestException, ServiceUnavailableException } from '@nestjs/common';
|
||||
import { selectDrainageReportTask } from '../common/drainage-report-task';
|
||||
import { isIP } from 'node:net';
|
||||
import { parse } from 'tldts';
|
||||
import type { PrismaService } from '../prisma/prisma.service';
|
||||
@@ -19,7 +20,7 @@ export type DrainageMaterial = {
|
||||
url: string;
|
||||
auditStatus: string;
|
||||
materialVersion: number;
|
||||
reportTasks: Array<{ id: string; channelId: string; carrier: string | null; status: string }>;
|
||||
reportTasks: Array<{ id: string; channelId: string; carrier: string | null; approvalScope?: string; status: string }>;
|
||||
};
|
||||
export type DrainageAssessment = {
|
||||
version: string;
|
||||
@@ -138,8 +139,9 @@ export function assessDrainage(
|
||||
}
|
||||
const channels = new Set(
|
||||
approved.flatMap((item) =>
|
||||
item.reportTasks
|
||||
.filter((task) => task.status === 'approved' && (!task.carrier || !carrier || task.carrier === carrier))
|
||||
[...new Set(item.reportTasks.map((task) => task.channelId))]
|
||||
.map((channelId) => selectDrainageReportTask(item.reportTasks, channelId, carrier))
|
||||
.filter((task): task is NonNullable<typeof task> => task?.status === 'approved')
|
||||
.map((task) => task.channelId),
|
||||
),
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user