mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-08 12:32:43 +00:00
Four smaller things around the same card. The configured flag came from the environment of whichever process serves the request. A hand-rolled split that gives BACKUP_S3_* to the worker and not to the web process would have shown an operator "nothing leaves this host" over a ledger full of fresh rows. The ledger is queried either way now, and a row in it outranks an environment read: a row is proof an upload happened. Rows sorted by username put the one account that needs attention wherever the alphabet leaves it, which on a hundred-account cohort is the crowd problem the card exists to end, moved from a count into a list. Worst verdict first, alphabetical within a verdict, decided server-side so the tests and the accessibility fixture see the order the operator does. The card's docblock claimed the worker holds PutObject and GetObject. The runbook is right and the multipart path needs AbortMultipartUpload too, so the prose no longer documents a grant that would break the uploader. And the byte formatter moved to lib. The off-host card was importing it out of a thousand-line client component, which costs nothing while both cards render on one route and becomes a cost the moment either moves.
23 lines
838 B
TypeScript
23 lines
838 B
TypeScript
import type { useFormatters } from "@/lib/i18n/context";
|
|
|
|
/**
|
|
* One spelling of "1.25 MB" for every surface that shows a byte count from
|
|
* the admin backups response.
|
|
*
|
|
* It lives here rather than beside the card that happened to need it first:
|
|
* the second reader was importing a formatter out of a thousand-line client
|
|
* component, which is a dependency on a page's worth of code for four lines of
|
|
* arithmetic. Both cards render on the same route today, so it costs nothing
|
|
* today — and it becomes a cost the moment either one moves.
|
|
*/
|
|
export function formatBytes(
|
|
bytes: number,
|
|
fmt: ReturnType<typeof useFormatters>,
|
|
): string {
|
|
if (bytes < 1024) return `${bytes} B`;
|
|
if (bytes < 1024 * 1024) {
|
|
return `${fmt.integer(Math.round(bytes / 1024))} KB`;
|
|
}
|
|
return `${fmt.number(bytes / 1024 / 1024, 2)} MB`;
|
|
}
|