All files / apps/developer-portal/layers/health/app/composables useCoveragePage.ts

100% Statements 10/10
75% Branches 3/4
100% Functions 3/3
100% Lines 8/8

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24      1x 8x 8x 8x 16x   8x           32x           8x    
import type { PageFact } from "~/types/PageFact";
 
/** The coverage snapshot and the header facts drawn from it. */
export const useCoveragePage = () => {
    const { t } = useI18n();
    const coverage = coverageArtifact();
    const projects = coverage?.projects ?? [];
    const collected = projects.filter((project) => project.collected).length;
 
    const provenance = t("coverage.provenance", {
        collected,
        total: projects.length,
        age: relativeTime(coverage?.generatedAt, t),
    });
 
    const facts = COVERAGE_METRICS.map((key): PageFact => ({
        label: t(`common.metrics.${key}`),
        value: dash(coverage?.totals?.[key], "%"),
        class: toneClass(coverageTone(coverage?.totals?.[key] ?? null)),
    }));
 
    return { coverage, projects, provenance, facts };
};