forked from Yara724/api
Fix searching on GET APIs
This commit is contained in:
@@ -28,9 +28,13 @@ import {
|
||||
getUnifiedFileStatusCatalog,
|
||||
resolveUnifiedFileStatus,
|
||||
} from "src/helpers/unified-file-status";
|
||||
import { applyListQueryV2 } from "src/helpers/list-query-v2";
|
||||
import { applyListQueryV2, isInListDateRange, parseListDateRange } from "src/helpers/list-query-v2";
|
||||
import { ClaimCaseDbService } from "src/claim-request-management/entites/db-service/claim-case.db.service";
|
||||
import { ListQueryV2Dto } from "src/common/dto/list-query-v2.dto";
|
||||
import {
|
||||
UnifiedFileStatusReportDto,
|
||||
UnifiedFileStatusReportQueryDto,
|
||||
} from "src/common/dto/unified-file-status-report.dto";
|
||||
import {
|
||||
ExpertFileAssignResultDto,
|
||||
ExpertFileAssignStatus,
|
||||
@@ -156,8 +160,25 @@ export class ExpertBlameService {
|
||||
});
|
||||
}
|
||||
|
||||
async getUnifiedFileStatusReportV2(actor: any) {
|
||||
const rows = await this.collectBlamePortfolioDocs(actor);
|
||||
async getUnifiedFileStatusReportV2(
|
||||
actor: any,
|
||||
query: UnifiedFileStatusReportQueryDto = {},
|
||||
): Promise<UnifiedFileStatusReportDto> {
|
||||
let rows = await this.collectBlamePortfolioDocs(actor);
|
||||
const { fromDate, toDate } = parseListDateRange(query.from, query.to);
|
||||
rows = rows.filter((doc) =>
|
||||
isInListDateRange(
|
||||
(doc as { createdAt?: Date }).createdAt,
|
||||
fromDate,
|
||||
toDate,
|
||||
),
|
||||
);
|
||||
if (query.fileType) {
|
||||
rows = rows.filter(
|
||||
(doc) =>
|
||||
String((doc as { type?: string }).type ?? "") === query.fileType,
|
||||
);
|
||||
}
|
||||
const claimByPublicId = await this.loadClaimsByPublicIds(
|
||||
rows.map((d) => String((d as { publicId?: string }).publicId ?? "")),
|
||||
);
|
||||
@@ -590,6 +611,8 @@ export class ExpertBlameService {
|
||||
claimStatus: claim?.status,
|
||||
});
|
||||
},
|
||||
fileType: (doc) =>
|
||||
String((doc as { type?: string }).type ?? "") || undefined,
|
||||
searchExtras: (doc) => {
|
||||
const d = doc as {
|
||||
_id?: unknown;
|
||||
|
||||
@@ -26,6 +26,10 @@ import { CurrentUser } from "src/decorators/user.decorator";
|
||||
import { RoleEnum } from "src/Types&Enums/role.enum";
|
||||
import { ExpertBlameService } from "./expert-blame.service";
|
||||
import { ListQueryV2Dto } from "src/common/dto/list-query-v2.dto";
|
||||
import {
|
||||
UnifiedFileStatusReportDto,
|
||||
UnifiedFileStatusReportQueryDto,
|
||||
} from "src/common/dto/unified-file-status-report.dto";
|
||||
import { AllRequestDtoRsV2 } from "./dto/all-request.dto";
|
||||
import { SubmitReplyDto } from "./dto/reply.dto";
|
||||
import { ResendRequestDto } from "./dto/resend.dto";
|
||||
@@ -44,8 +48,9 @@ export class ExpertBlameV2Controller {
|
||||
description:
|
||||
"Damage experts (`expert`): tenant-scoped **DISAGREEMENT** queue (available, locked, or decided by you). " +
|
||||
"Field experts (`field_expert`): all expert-initiated blame files they created (LINK + IN_PERSON). Use expert-claim for claims after blame completion. " +
|
||||
"Optional query: `search`, `sortBy` (publicId | createdAt | requestNo | status), `sortOrder`, `page`, `limit`, `unifiedStatus` (calculated blame+claim status).",
|
||||
"Optional query: `search`, `sortBy` (publicId | createdAt | requestNo | status), `sortOrder`, `page`, `limit`, `unifiedStatus`, `fileType` (THIRD_PARTY | CAR_BODY).",
|
||||
})
|
||||
@ApiResponse({ status: 200, type: AllRequestDtoRsV2 })
|
||||
async findAll(
|
||||
@CurrentUser() actor: any,
|
||||
@Query() query: ListQueryV2Dto,
|
||||
@@ -64,11 +69,18 @@ export class ExpertBlameV2Controller {
|
||||
@ApiOperation({
|
||||
summary: "Unified file status catalog + counts (blame + linked claim)",
|
||||
description:
|
||||
"Calculatable statuses for this expert's blame portfolio. Filter lists with `unifiedStatus` query param.",
|
||||
"Calculatable statuses for this expert's blame portfolio. Filter lists with `unifiedStatus` and `fileType` query params. Optional `from` / `to` ISO dates narrow the counted portfolio.",
|
||||
})
|
||||
async getUnifiedFileStatusReportV2(@CurrentUser() actor: any) {
|
||||
@ApiResponse({ status: 200, type: UnifiedFileStatusReportDto })
|
||||
async getUnifiedFileStatusReportV2(
|
||||
@CurrentUser() actor: any,
|
||||
@Query() query: UnifiedFileStatusReportQueryDto,
|
||||
): Promise<UnifiedFileStatusReportDto> {
|
||||
try {
|
||||
return await this.expertBlameService.getUnifiedFileStatusReportV2(actor);
|
||||
return await this.expertBlameService.getUnifiedFileStatusReportV2(
|
||||
actor,
|
||||
query,
|
||||
);
|
||||
} catch (error) {
|
||||
if (error instanceof HttpException) throw error;
|
||||
throw new InternalServerErrorException(
|
||||
|
||||
Reference in New Issue
Block a user