forked from Yara724/api
Calculate insurer report review duration
This commit is contained in:
@@ -264,6 +264,18 @@ export class ExpertInsurerService {
|
||||
return String(aid);
|
||||
}
|
||||
|
||||
private calculateReviewDurationMinutes(
|
||||
createdAt: Date | string | undefined,
|
||||
updatedAt: Date | string | undefined,
|
||||
): number | null {
|
||||
const startedAtMs = new Date(createdAt as any).getTime();
|
||||
const reviewedAtMs = new Date(updatedAt as any).getTime();
|
||||
if (Number.isNaN(startedAtMs) || Number.isNaN(reviewedAtMs)) return null;
|
||||
|
||||
const durationMinutes = Math.max(reviewedAtMs - startedAtMs, 0) / 60_000;
|
||||
return Math.round(durationMinutes * 100) / 100;
|
||||
}
|
||||
|
||||
private mapBlameFileSummaryForInsurerExpert(b: any) {
|
||||
return {
|
||||
kind: "blame" as const,
|
||||
@@ -275,6 +287,10 @@ export class ExpertInsurerService {
|
||||
blameStatus: b.blameStatus,
|
||||
createdAt: b.createdAt,
|
||||
updatedAt: b.updatedAt,
|
||||
reviewDurationMinutes: this.calculateReviewDurationMinutes(
|
||||
b.createdAt,
|
||||
b.updatedAt,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -288,6 +304,10 @@ export class ExpertInsurerService {
|
||||
claimStatus: c.claimStatus,
|
||||
createdAt: c.createdAt,
|
||||
updatedAt: c.updatedAt,
|
||||
reviewDurationMinutes: this.calculateReviewDurationMinutes(
|
||||
c.createdAt,
|
||||
c.updatedAt,
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user