mirror of
https://github.com/fabro-sh/fabro.git
synced 2026-09-05 08:10:39 +00:00
Expand the OpenAPI spec from 11 to 39 endpoints covering Runs, Workflows, Verifications, Retros, Sessions, Insights, Settings, and Projects with ~45 schemas. Add `--demo` flag to `arc serve` that serves static demo data for all endpoints (auth disabled, read-only). Non-demo mode returns 501 for new endpoints while existing run handlers continue working. Regenerate the TypeScript API client and add `apiJson` helper. Wire all 19 React route files with server-side loaders that fetch from the API and map snake_case responses to camelCase UI types. Mock data kept as fallback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
35 lines
1.2 KiB
TypeScript
35 lines
1.2 KiB
TypeScript
/**
|
|
* Format a number of seconds into a human-readable duration string.
|
|
* Examples: "23s", "7m", "2h 15m", "3d"
|
|
*/
|
|
export function formatElapsedSecs(secs: number): string {
|
|
if (secs < 60) return `${Math.round(secs)}s`;
|
|
const minutes = Math.floor(secs / 60);
|
|
if (minutes < 60) {
|
|
const remainSecs = Math.round(secs % 60);
|
|
return remainSecs > 0 ? `${minutes}m ${remainSecs}s` : `${minutes}m`;
|
|
}
|
|
const hours = Math.floor(minutes / 60);
|
|
if (hours < 24) {
|
|
const remainMin = minutes % 60;
|
|
return remainMin > 0 ? `${hours}h ${remainMin}m` : `${hours}h`;
|
|
}
|
|
const days = Math.floor(hours / 24);
|
|
const remainHrs = hours % 24;
|
|
return remainHrs > 0 ? `${days}d ${remainHrs}h` : `${days}d`;
|
|
}
|
|
|
|
/**
|
|
* Format seconds into a duration string for display (e.g., "1m 12s", "23s").
|
|
*/
|
|
export function formatDurationSecs(secs: number): string {
|
|
if (secs < 60) return `${Math.round(secs)}s`;
|
|
const minutes = Math.floor(secs / 60);
|
|
const remainSecs = Math.round(secs % 60);
|
|
if (minutes < 60) {
|
|
return remainSecs > 0 ? `${minutes}m ${remainSecs}s` : `${minutes}m`;
|
|
}
|
|
const hours = Math.floor(minutes / 60);
|
|
const remainMin = minutes % 60;
|
|
return remainMin > 0 ? `${hours}h ${remainMin}m` : `${hours}h`;
|
|
}
|