forked from Yara724/api
YARA-1246
This commit is contained in:
@@ -40,6 +40,8 @@ import {
|
||||
CreateFileReviewerByInsurerDto,
|
||||
} from "./dto/create-insurer-expert.dto";
|
||||
import {
|
||||
InsurerChartsDto,
|
||||
InsurerExpertsListResponseDto,
|
||||
InsurerStatisticsDto,
|
||||
InsurerTopExpertsDto,
|
||||
InsurerTopFileDto,
|
||||
@@ -148,13 +150,30 @@ export class ExpertInsurerController {
|
||||
|
||||
@ApiQuery({ name: "page", type: Number })
|
||||
@ApiQuery({ name: "response_count", type: Number })
|
||||
@ApiQuery({ name: "from", required: false, description: "Optional start datetime (ISO string)" })
|
||||
@ApiQuery({ name: "to", required: false, description: "Optional end datetime (ISO string)" })
|
||||
@ApiQuery({
|
||||
name: "periodDays",
|
||||
required: false,
|
||||
enum: [30, 60, 90],
|
||||
description: "Preset reporting window. Default: 30 days when from/to are omitted.",
|
||||
})
|
||||
@ApiResponse({ status: 200, type: InsurerExpertsListResponseDto })
|
||||
@Get("experts/list")
|
||||
async getAllExperts(
|
||||
@Query("page") page: number,
|
||||
@Query("response_count") count: number,
|
||||
@Query("from") from: string | undefined,
|
||||
@Query("to") to: string | undefined,
|
||||
@Query("periodDays") periodDays: string | undefined,
|
||||
@CurrentUser() actor,
|
||||
) {
|
||||
return await this.expertInsurerService.retrieveAllExpertsOfClient(actor, page, count);
|
||||
return await this.expertInsurerService.retrieveAllExpertsOfClient(
|
||||
actor,
|
||||
page,
|
||||
count,
|
||||
{ from, to, periodDays },
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Reports: statistics ──────────────────────────────────────────────────
|
||||
@@ -163,64 +182,91 @@ export class ExpertInsurerController {
|
||||
@ApiOperation({
|
||||
summary: "نمایش کلی — KPI cards for insurer reports page",
|
||||
description:
|
||||
"Returns `totalFilesReviewed` (distinct tenant claim files with ≥1 expert CHECKED activity), " +
|
||||
"`averageUserRatingPercentage` (mean of progressSpeed + registrationEase + overallEvaluation across rated files, normalised to 0–100), " +
|
||||
"`inPersonAccompaniedCount` (blame files where expertInitiated=true AND creationMethod=IN_PERSON), " +
|
||||
"`filesCreatedThisMonth`, `totalFiles`, `objectionPercentage`, `insurerToBotRatingPercentage`. " +
|
||||
"⚠️ `userRatingPercentage` and `filesWithUserRatingPercentage` are the share of files *that have any user rating* — NOT a satisfaction score. Use `averageUserRatingPercentage` for رضایت کاربران.",
|
||||
"Returns the four main KPIs for the selected reporting range: total third-party files, total car-body files, total files, and active experts. " +
|
||||
"Also returns reviewed/unreviewed totals with third-party/car-body breakdown using the same range logic as the expert table and charts.",
|
||||
})
|
||||
@ApiQuery({ name: "from", required: false, description: "Optional start datetime (ISO string) — restricts counted claim portfolio" })
|
||||
@ApiQuery({ name: "from", required: false, description: "Optional start datetime (ISO string)" })
|
||||
@ApiQuery({ name: "to", required: false, description: "Optional end datetime (ISO string)" })
|
||||
@ApiQuery({
|
||||
name: "periodDays",
|
||||
required: false,
|
||||
enum: [30, 60, 90],
|
||||
description: "Preset reporting window. Default: 30 days when from/to are omitted.",
|
||||
})
|
||||
@ApiResponse({ status: 200, type: InsurerStatisticsDto })
|
||||
async getExpertStatistics(
|
||||
@CurrentUser() actor,
|
||||
@Query("from") from?: string,
|
||||
@Query("to") to?: string,
|
||||
@Query("periodDays") periodDays?: string,
|
||||
) {
|
||||
return await this.expertInsurerService.getExpertStatisticsReport(actor, { from, to });
|
||||
return await this.expertInsurerService.getExpertStatisticsReport(actor, {
|
||||
from,
|
||||
to,
|
||||
periodDays,
|
||||
});
|
||||
}
|
||||
|
||||
// ─── Reports: top files ───────────────────────────────────────────────────
|
||||
|
||||
@Get("top-files")
|
||||
@ApiOperation({
|
||||
summary: "Top 10 highest-rated claim files for this insurer",
|
||||
summary: "[Legacy] Top 10 highest-rated claim files for this insurer",
|
||||
description:
|
||||
"Sorted by combined insurer + user rating blend (getCombinedFileScore). " +
|
||||
"Returns slim DTO only: publicId, createdAt, combinedScore, userRating.{comment, overallEvaluation}. " +
|
||||
"Use publicId to build مشاهده پرونده links.",
|
||||
"Legacy rating-based report endpoint. It is kept for backward compatibility but is no longer needed for the new insurer KPI/reporting page.",
|
||||
deprecated: true,
|
||||
})
|
||||
@ApiQuery({ name: "from", required: false, description: "Restrict to files created on or after this ISO date" })
|
||||
@ApiQuery({ name: "to", required: false, description: "Restrict to files created on or before this ISO date" })
|
||||
@ApiQuery({
|
||||
name: "periodDays",
|
||||
required: false,
|
||||
enum: [30, 60, 90],
|
||||
description: "Preset reporting window. Default: 30 days when from/to are omitted.",
|
||||
})
|
||||
@ApiResponse({ status: 200, type: [InsurerTopFileDto] })
|
||||
async getTopFiles(
|
||||
@CurrentUser() insurer,
|
||||
@Query("from") from?: string,
|
||||
@Query("to") to?: string,
|
||||
@Query("periodDays") periodDays?: string,
|
||||
) {
|
||||
return await this.expertInsurerService.getTopFilesForClient(insurer.clientKey, { from, to });
|
||||
return await this.expertInsurerService.getTopFilesForClient(insurer.clientKey, {
|
||||
from,
|
||||
to,
|
||||
periodDays,
|
||||
});
|
||||
}
|
||||
|
||||
// ─── Reports: top experts (canonical + alias) ─────────────────────────────
|
||||
|
||||
@Get("experts/top")
|
||||
@ApiOperation({
|
||||
summary: "Top blame vs claim experts for this insurer",
|
||||
summary: "Top 10 experts by file count for this insurer",
|
||||
description:
|
||||
"Response: `{ blameExperts: [], claimExperts: [] }`. " +
|
||||
"Each item: `_id`, `fullName`, `expertKind`, `overallAverageRating`, `requestStats`. " +
|
||||
"Sorted by overallAverageRating descending; up to 10 per group. " +
|
||||
"Optional `from` / `to` accepted for forward-compat (currently accepted but roster is full-history).",
|
||||
"Returns a single top-10 expert list ranked by total attributed files inside the selected reporting range. " +
|
||||
"Each row includes reviewed/unreviewed and third-party/car-body breakdowns.",
|
||||
})
|
||||
@ApiQuery({ name: "from", required: false, description: "Optional start datetime (ISO string)" })
|
||||
@ApiQuery({ name: "to", required: false, description: "Optional end datetime (ISO string)" })
|
||||
@ApiQuery({
|
||||
name: "periodDays",
|
||||
required: false,
|
||||
enum: [30, 60, 90],
|
||||
description: "Preset reporting window. Default: 30 days when from/to are omitted.",
|
||||
})
|
||||
@ApiResponse({ status: 200, type: InsurerTopExpertsDto })
|
||||
async getTopExperts(
|
||||
@CurrentUser() actor,
|
||||
@Query("from") from?: string,
|
||||
@Query("to") to?: string,
|
||||
@Query("periodDays") periodDays?: string,
|
||||
) {
|
||||
return await this.expertInsurerService.getTopExpertsForClient(actor, { from, to });
|
||||
return await this.expertInsurerService.getTopExpertsForClient(actor, {
|
||||
from,
|
||||
to,
|
||||
periodDays,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -229,18 +275,52 @@ export class ExpertInsurerController {
|
||||
*/
|
||||
@Get("top-experts")
|
||||
@ApiOperation({
|
||||
summary: "Alias for GET experts/top — top blame + claim experts",
|
||||
summary: "Alias for GET experts/top — top 10 experts by file count",
|
||||
description: "Same response as `GET experts/top`. Provided for front-end compatibility.",
|
||||
})
|
||||
@ApiQuery({ name: "from", required: false })
|
||||
@ApiQuery({ name: "to", required: false })
|
||||
@ApiQuery({ name: "periodDays", required: false, enum: [30, 60, 90] })
|
||||
@ApiResponse({ status: 200, type: InsurerTopExpertsDto })
|
||||
async getTopExpertsAlias(
|
||||
@CurrentUser() actor,
|
||||
@Query("from") from?: string,
|
||||
@Query("to") to?: string,
|
||||
@Query("periodDays") periodDays?: string,
|
||||
) {
|
||||
return await this.expertInsurerService.getTopExpertsForClient(actor, { from, to });
|
||||
return await this.expertInsurerService.getTopExpertsForClient(actor, {
|
||||
from,
|
||||
to,
|
||||
periodDays,
|
||||
});
|
||||
}
|
||||
|
||||
@Get("report/charts")
|
||||
@ApiOperation({
|
||||
summary: "Chart datasets for insurer reports",
|
||||
description:
|
||||
"Returns all chart-ready datasets for the selected reporting range: top 10 experts by total files, files per expert for third-party and car-body, daily file counts, and daily average handling time.",
|
||||
})
|
||||
@ApiQuery({ name: "from", required: false, description: "Optional start datetime (ISO string)" })
|
||||
@ApiQuery({ name: "to", required: false, description: "Optional end datetime (ISO string)" })
|
||||
@ApiQuery({
|
||||
name: "periodDays",
|
||||
required: false,
|
||||
enum: [30, 60, 90],
|
||||
description: "Preset reporting window. Default: 30 days when from/to are omitted.",
|
||||
})
|
||||
@ApiResponse({ status: 200, type: InsurerChartsDto })
|
||||
async getReportCharts(
|
||||
@CurrentUser() actor,
|
||||
@Query("from") from?: string,
|
||||
@Query("to") to?: string,
|
||||
@Query("periodDays") periodDays?: string,
|
||||
) {
|
||||
return this.expertInsurerService.getReportCharts(actor, {
|
||||
from,
|
||||
to,
|
||||
periodDays,
|
||||
});
|
||||
}
|
||||
|
||||
// ─── Reports: work-log (delegates to ReportsService) ─────────────────────
|
||||
@@ -258,6 +338,12 @@ export class ExpertInsurerController {
|
||||
@ApiQuery({ name: "expertKind", required: false, enum: ["all", "expert", "damage_expert"], description: "Filter by expert kind" })
|
||||
@ApiQuery({ name: "from", required: false, description: "Start of date window (ISO string)" })
|
||||
@ApiQuery({ name: "to", required: false, description: "End of date window (ISO string)" })
|
||||
@ApiQuery({
|
||||
name: "periodDays",
|
||||
required: false,
|
||||
enum: [30, 60, 90],
|
||||
description: "Preset reporting window. Default: 30 days when from/to are omitted.",
|
||||
})
|
||||
@ApiQuery({ name: "page", required: false, type: Number, description: "Page (1-based)" })
|
||||
@ApiQuery({ name: "limit", required: false, type: Number, description: "Items per page" })
|
||||
@ApiResponse({ status: 200, type: InsurerWorkLogResponseDto })
|
||||
@@ -266,6 +352,7 @@ export class ExpertInsurerController {
|
||||
@Query("expertKind") expertKind?: "all" | "expert" | "damage_expert",
|
||||
@Query("from") from?: string,
|
||||
@Query("to") to?: string,
|
||||
@Query("periodDays") periodDays?: string,
|
||||
@Query("page") page?: string,
|
||||
@Query("limit") limit?: string,
|
||||
) {
|
||||
@@ -273,6 +360,7 @@ export class ExpertInsurerController {
|
||||
expertKind,
|
||||
from,
|
||||
to,
|
||||
periodDays,
|
||||
page: page ? parseInt(page, 10) : undefined,
|
||||
limit: limit ? parseInt(limit, 10) : undefined,
|
||||
});
|
||||
@@ -355,12 +443,19 @@ export class ExpertInsurerController {
|
||||
})
|
||||
@ApiQuery({ name: "from", required: false, description: "Optional start datetime (ISO string)" })
|
||||
@ApiQuery({ name: "to", required: false, description: "Optional end datetime (ISO string)" })
|
||||
@ApiQuery({ name: "periodDays", required: false, enum: [30, 60, 90] })
|
||||
async getInsurerStatusReport(
|
||||
@CurrentUser() actor,
|
||||
@Query("from") from?: string,
|
||||
@Query("to") to?: string,
|
||||
@Query("periodDays") periodDays?: string,
|
||||
) {
|
||||
return await this.expertInsurerService.getInsurerFileStatusCounts(actor, from, to);
|
||||
return await this.expertInsurerService.getInsurerFileStatusCounts(
|
||||
actor,
|
||||
from,
|
||||
to,
|
||||
periodDays,
|
||||
);
|
||||
}
|
||||
|
||||
// ─── Expert detail ────────────────────────────────────────────────────────
|
||||
|
||||
Reference in New Issue
Block a user