Astra: AR and gap business actions, usage fixes, client report coverage, health check, backups and alerts, cancel_invoice fix (d52c9b976774)
cdfb5de verified Download web/src/domain/homeStats.ts from EnergyVenom/patchwise-agent-studio: direct link, hf CLI and curl.
- Browser
- Download file 2.41 kB
-
https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/domain/homeStats.ts
- Command line
-
hf download hf://spaces/EnergyVenom/patchwise-agent-studio/web/src/domain/homeStats.ts
-
curl -L -o homeStats.ts https://huggingface.co/spaces/EnergyVenom/patchwise-agent-studio/resolve/main/web/src/domain/homeStats.ts
2.41 kB
| import type { Schemas } from '../api/client'; | |
| type RunSummary = Schemas['RunSummary']; | |
| /** Minutes a person needs to run one scenario by hand: the stated basis of "effort saved" (an estimate, shown as one). */ | |
| export const MANUAL_MINUTES_PER_SCENARIO = 20; | |
| const ENDED = ['completed', 'failed', 'killed', 'cancelled', 'interrupted']; | |
| const n = (c: Record<string, number> | undefined, k: string) => c?.[k] ?? 0; | |
| /** What the test runs executed to date: scenarios run, their results, and the test cycles (runs that executed any). */ | |
| export function regressionToDate(runs: RunSummary[]) { | |
| let passed = 0, failed = 0, skipped = 0, cycles = 0; | |
| for (const r of runs) { | |
| const ran = n(r.counts, 'passed') + n(r.counts, 'failed'); | |
| if (!ran) continue; | |
| cycles += 1; | |
| passed += n(r.counts, 'passed'); | |
| failed += n(r.counts, 'failed'); | |
| skipped += n(r.counts, 'skipped'); | |
| } | |
| const executed = passed + failed; | |
| return { passed, failed, skipped, executed, cycles, passRate: executed ? Math.round((passed / executed) * 100) : null }; | |
| } | |
| /** Hours of manual testing the executed scenarios stand for, at MANUAL_MINUTES_PER_SCENARIO each. */ | |
| export const effortSavedHours = (executed: number) => Math.round((executed * MANUAL_MINUTES_PER_SCENARIO) / 60); | |
| export type CycleStage = 'in_progress' | 'completed' | 'stopped'; | |
| export interface UpdateCycle { patch: string; stage: CycleStage; runs: number; passed: number; failed: number; last: string } | |
| /** One line per Oracle update (patch) tested: its stage from its newest run, its test cycles and their results; newest | |
| * update first. Runs without a patch are left out (they test no update). */ | |
| export function updateCycles(runs: RunSummary[]): UpdateCycle[] { | |
| const by = new Map<string, RunSummary[]>(); | |
| for (const r of runs) if (r.patch_id) by.set(r.patch_id, [...(by.get(r.patch_id) ?? []), r]); | |
| const out: UpdateCycle[] = []; | |
| for (const [patch, rs] of by) { | |
| const newest = rs.reduce((a, b) => (b.created_at > a.created_at ? b : a)); | |
| const stage: CycleStage = !ENDED.includes(newest.status) ? 'in_progress' : newest.status === 'completed' ? 'completed' : 'stopped'; | |
| out.push({ patch, stage, runs: rs.length, passed: rs.reduce((s, r) => s + n(r.counts, 'passed'), 0), | |
| failed: rs.reduce((s, r) => s + n(r.counts, 'failed'), 0), last: newest.created_at }); | |
| } | |
| return out.sort((a, b) => b.last.localeCompare(a.last)); | |
| } | |