/**
 * Compare estimation.devHours vs actuals.devHours for every done spec
 * that has recorded actuals.
 *
 * accuracy = 100 - |estimated - actual| / estimated * 100
 * Clamped to [0, 100].
 */
export function computeAccuracy(specs) {
    const records = [];
    for (const spec of specs) {
        if (spec.status !== 'done' || !spec.actuals) {
            continue;
        }
        const estimated = spec.estimation.devHours;
        const actual = spec.actuals.devHours;
        if (estimated <= 0) {
            continue;
        }
        const accuracy = Math.max(0, 100 - (Math.abs(estimated - actual) / estimated) * 100);
        records.push({ specId: spec.id, estimated, actual, accuracy: Math.round(accuracy * 10) / 10 });
    }
    return records;
}
//# sourceMappingURL=accuracy-aggregator.js.map