1
0
forked from Yara724/api

Fix searching on GET APIs

This commit is contained in:
SepehrYahyaee
2026-06-23 10:22:46 +03:30
parent 16d3c54613
commit c6b417ced7
9 changed files with 223 additions and 45 deletions

View File

@@ -40,7 +40,15 @@ import { enrichBlamePartiesForAgreementView } from "src/helpers/blame-party-agre
import { BlameRequestType } from "src/Types&Enums/blame-request-management/blameRequestType.enum";
import { PartyRole } from "src/request-management/entities/schema/partyRole.enum";
import { ListQueryV2Dto } from "src/common/dto/list-query-v2.dto";
import { applyListQueryV2 } from "src/helpers/list-query-v2";
import {
UnifiedFileStatusReportDto,
UnifiedFileStatusReportQueryDto,
} from "src/common/dto/unified-file-status-report.dto";
import {
applyListQueryV2,
isInListDateRange,
parseListDateRange,
} from "src/helpers/list-query-v2";
import {
countUnifiedFileStatuses,
getUnifiedFileStatusCatalog,
@@ -1328,6 +1336,7 @@ export class ExpertInsurerService {
createdAt: (f) => f.updatedAt ?? f.createdAt,
requestNo: (f) => f.publicId,
status: (f) => f.unifiedFileStatus,
fileType: (f) => f.fileType,
searchExtras: (f) =>
[
f.fileType,
@@ -1352,16 +1361,18 @@ export class ExpertInsurerService {
async getInsurerUnifiedFileStatusReport(
actor: any,
from?: string,
to?: string,
) {
query: UnifiedFileStatusReportQueryDto = {},
): Promise<UnifiedFileStatusReportDto> {
const clientObjectId = this.getClientId(actor);
const { fromDate, toDate } = this.parseDateRange(from, to);
const { fromDate, toDate } = parseListDateRange(query.from, query.to);
const files = await this.buildMergedInsurerFiles(clientObjectId);
const inRange = files.filter((f) =>
this.isInDateRange(f.createdAt, fromDate, toDate),
let inRange = files.filter((f) =>
isInListDateRange(f.createdAt, fromDate, toDate),
);
if (query.fileType) {
inRange = inRange.filter((f) => f.fileType === query.fileType);
}
return {
statuses: getUnifiedFileStatusCatalog(),
@@ -1946,7 +1957,10 @@ export class ExpertInsurerService {
under_review: number;
waiting_for_documents_resend: number;
}> {
const report = await this.getInsurerUnifiedFileStatusReport(actor, from, to);
const report = await this.getInsurerUnifiedFileStatusReport(actor, {
from,
to,
});
const counts = report.counts;
return {
all: counts.all ?? 0,