forked from Yara724/api
YARA-1078
This commit is contained in:
@@ -436,19 +436,47 @@ export class ReportsService {
|
||||
});
|
||||
}
|
||||
|
||||
async getInsurerExpertWorkLog(actor: {
|
||||
clientKey?: string;
|
||||
}): Promise<InsurerExpertWorkLogResponseDtoRs> {
|
||||
async getInsurerExpertWorkLog(
|
||||
actor: { clientKey?: string },
|
||||
opts: {
|
||||
expertKind?: "all" | "expert" | "damage_expert";
|
||||
from?: string;
|
||||
to?: string;
|
||||
page?: number;
|
||||
limit?: number;
|
||||
} = {},
|
||||
): Promise<{ experts: InsurerExpertWorkLogEntryDtoRs[]; total: number }> {
|
||||
const clientKey = requireActorClientKey(actor);
|
||||
const { events, expertRows } =
|
||||
await this.loadTenantExpertsAndActivities(clientKey);
|
||||
|
||||
// expertKind filter
|
||||
const filteredRows =
|
||||
!opts.expertKind || opts.expertKind === "all"
|
||||
? expertRows
|
||||
: expertRows.filter((r) => r.kind === opts.expertKind);
|
||||
|
||||
const now = new Date();
|
||||
const epoch = new Date(0);
|
||||
const entries = this.buildWorkLogEntries(expertRows, events, now, {
|
||||
from: epoch,
|
||||
to: now,
|
||||
|
||||
// When from/to supplied, distinctFilesCheckedInPeriod is restricted to that window;
|
||||
// totalHandled and currentlyChecking are snapshot-at-'to' (or now when to is absent).
|
||||
const { fromDate, toDate } = this.parseDateRange(opts.from, opts.to);
|
||||
const cutoff = toDate ?? now;
|
||||
const checkedFrom = fromDate ?? new Date(0);
|
||||
const checkedTo = toDate ?? now;
|
||||
|
||||
const entries = this.buildWorkLogEntries(filteredRows, events, cutoff, {
|
||||
from: checkedFrom,
|
||||
to: checkedTo,
|
||||
});
|
||||
return new InsurerExpertWorkLogResponseDtoRs(entries);
|
||||
|
||||
// Optional pagination
|
||||
const page = Number(opts.page) > 0 ? Number(opts.page) : 1;
|
||||
const limit = Number(opts.limit) > 0 ? Number(opts.limit) : entries.length;
|
||||
const start = (page - 1) * limit;
|
||||
const paged = entries.slice(start, start + limit);
|
||||
|
||||
return { experts: paged, total: entries.length };
|
||||
}
|
||||
|
||||
async getInsurerExpertWorkLogPerMonth(actor: {
|
||||
|
||||
Reference in New Issue
Block a user