fix(version): 修正概览耗时与排名统计

This commit is contained in:
Script Generator
2026-06-26 13:06:22 +08:00
parent 4cda624dc7
commit dde7a9a623
9 changed files with 857 additions and 367 deletions

View File

@@ -1,7 +1,7 @@
import type { Priority } from './derive';
import type { Reference } from './dev-task';
import { DEFAULT_TEST_CATEGORY_ID } from './task-category';
import { calcWorkHours, type TimeInterval } from './work-hours';
import { calcActualElapsedHours, type TimeInterval } from './work-hours';
import { aggregateWorkEffort } from './work-effort-engine';
export type TestCaseStatus = 'pending' | 'running' | 'passed' | 'failed' | 'blocked';
@@ -138,8 +138,9 @@ export function getTestCaseEstimateHours(tc: TestCase): number {
export function getTestCaseActualHours(tc: TestCase, now: Date = new Date()): number {
if (!tc.startedAt) return 0;
const end = tc.completedAt ?? now.toISOString();
return calcWorkHours(tc.startedAt, end);
const isTerminal = tc.status === 'passed' || tc.status === 'failed' || tc.status === 'blocked';
const end = tc.completedAt ?? (isTerminal ? tc.updatedAt : now.toISOString());
return calcActualElapsedHours(tc.startedAt, end);
}
export function aggregateTestCaseHours(cases: TestCase[], now: Date = new Date()): { estimate: number; actual: number } {
@@ -166,7 +167,8 @@ export function testCaseIntervals(cases: TestCase[], now: Date = new Date()): Ti
const nowIso = now.toISOString();
for (const c of cases) {
if (!c.startedAt) continue;
out.push({ start: c.startedAt, end: c.completedAt ?? nowIso });
const isTerminal = c.status === 'passed' || c.status === 'failed' || c.status === 'blocked';
out.push({ start: c.startedAt, end: c.completedAt ?? (isTerminal ? c.updatedAt : nowIso) });
}
return out;
}