All files / apps/developer-portal/layers/snapshot/app/utils metrics.ts

100% Statements 7/7
80% Branches 8/10
100% Functions 5/5
100% Lines 5/5

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      34x 7x     34x   7x 2x  
import type { ProjectMetrics } from "../../shared/types/ProjectMetrics.ts";
 
/** Spec files across every project; `null` when nothing was collected. */
export const specTotal = (projects: readonly ProjectMetrics[] | undefined): number | null =>
    projects?.length ? projects.reduce((sum, project) => sum + project.specs, 0) : null;
 
/** Projects with commits since their last release, the furthest behind first. */
export const unreleased = (projects: readonly ProjectMetrics[] | undefined): ProjectMetrics[] =>
    (projects ?? [])
        .filter((project) => (project.unreleasedCommits ?? 0) > 0)
        .sort((a, b) => (b.unreleasedCommits ?? 0) - (a.unreleasedCommits ?? 0));