diff --git a/frontend/src/components/BugStats.astro b/frontend/src/components/BugStats.astro index 1aedaee..e49e5eb 100644 --- a/frontend/src/components/BugStats.astro +++ b/frontend/src/components/BugStats.astro @@ -1,21 +1,126 @@ --- +import type { Temporal } from "@js-temporal/polyfill"; import { formatRoundAge } from "@lib/formatRoundAge"; import type { AgeStats } from "@lib/repo-summaries"; interface Props { ageStats: AgeStats; description: string; + /** The global maximum bug age, to render at the right side of the chart. */ + maxAge: Temporal.Duration; } -const { ageStats, description } = Astro.props; +const { ageStats, description, maxAge } = Astro.props; -const percentiles = [10, 25, 50, 75, 90]; +const maxAgeS = maxAge.total("seconds"); +const p10Frac = + Math.round((ageStats[10].total("seconds") / maxAgeS) * 1000) / 10; +const p25Frac = + Math.round((ageStats[25].total("seconds") / maxAgeS) * 1000) / 10; +const p50Frac = + Math.round((ageStats[50].total("seconds") / maxAgeS) * 1000) / 10; +const p75Frac = + Math.round((ageStats[75].total("seconds") / maxAgeS) * 1000) / 10; +const p90Frac = + Math.round((ageStats[90].total("seconds") / maxAgeS) * 1000) / 10; +const meanFrac = + Math.round((ageStats.mean.total("seconds") / maxAgeS) * 1000) / 10; --- -
{ageStats.count}{' '}{description}: mean age {formatRoundAge(ageStats.mean)}
-{p}th %ile | )}
---|
{formatRoundAge(ageStats[p])} | )}