diff --git a/README.md b/README.md index 6ac12aab..fadde8e1 100644 --- a/README.md +++ b/README.md @@ -22,7 +22,7 @@ Pulse snapshots it. | Page | What it shows | |---|---| | `/` Downloads | Headline downloads with change vs. the previous period, daily or weekly trend stacked by artifact type or by source, weekly share of downloads by product, and a sortable, searchable leaderboard. | -| `/product/:id` | One product: every artifact with its own counts, version adoption over the last 30 days and version share over time, PyPI downloads by Python version and OS, release cadence, repository health, stars over time, open issues and PRs, recent releases, GitHub traffic. | +| `/product/:id` | One product: downloads by source with stable releases marked, downloads in the 14 days before and after each recent release, every artifact with its own counts, version adoption over the last 30 days and version share over time, PyPI downloads by Python version and OS, release cadence, repository health, stars over time, open issues and PRs, recent releases, GitHub traffic. | | `/traffic` | GitHub traffic: unique visitors and cloners for the last 14 days with change vs. the 14 before, totals, and daily history for all tracked repos. | | `/repos` | Repository health: stars and stars gained, open issues and PRs, PRs merged in 30 days, authors in 30 days, last push, with new and active contributors over time, open issues and PRs over time, and release cadence per product (latest release and age, releases in the last 90 days, median gap over the last year, releases per week). `/releases` redirects here. | | `/docs` | Documentation traffic for the docs sites (Nebari, Nebari Classic, Software Packs, Nebi, JHub Apps): visits per site with change vs. the previous period, visits over time by site, and one table of the top pages over the last 7 days across all sites, with a site filter and search. | diff --git a/site/AGENTS.md b/site/AGENTS.md index fed6f67f..686e541c 100644 --- a/site/AGENTS.md +++ b/site/AGENTS.md @@ -52,6 +52,7 @@ pulse-dashboard/ │ │ ├── ShareChart/ # 100% stacked weekly share by product (lib/summary.ts shareRows) │ │ ├── ReleaseCadence/ # cadence per product, on the Repos page │ │ ├── RedirectTo/ # retired paths (/releases) to their new home, query kept +│ │ ├── ReleaseImpact/ # downloads 14 days before and after each release (Product page) │ │ ├── StatRow/ # one slim surface for a page's headline figures; each StatTile has its own (i) │ │ ├── Filters/, Leaderboard/, StatTile/, TrendChart/, Sparkline/ │ ├── pages/ diff --git a/site/src/components/ReleaseImpact/ReleaseImpact.test.tsx b/site/src/components/ReleaseImpact/ReleaseImpact.test.tsx new file mode 100644 index 00000000..212be102 --- /dev/null +++ b/site/src/components/ReleaseImpact/ReleaseImpact.test.tsx @@ -0,0 +1,50 @@ +import { render, screen, within } from '@testing-library/react'; +import ReleaseImpact from './ReleaseImpact'; + +const release = (tag: string, date: string) => ({ + tag, + date, + prerelease: false, + repo: 'nebari-dev/nebari-operator', +}); + +describe('ReleaseImpact', () => { + it('shows before, after and change, with dashes for unknown windows', () => { + render( + , + ); + const table = screen.getByRole('table', { + name: /14 days before and after/, + }); + const [filling, done] = within(table).getAllByRole('row').slice(1); + expect(within(done).getByText('+50%')).toBeInTheDocument(); + expect(within(done).getByText('150')).toBeInTheDocument(); + expect(within(filling).getByText('(still filling)')).toBeInTheDocument(); + expect( + within(filling).getByRole('link', { name: /v1.3.0/ }), + ).toHaveAttribute( + 'href', + 'https://github.com/nebari-dev/nebari-operator/releases/tag/v1.3.0', + ); + }); +}); diff --git a/site/src/components/ReleaseImpact/ReleaseImpact.tsx b/site/src/components/ReleaseImpact/ReleaseImpact.tsx new file mode 100644 index 00000000..b30c8a4b --- /dev/null +++ b/site/src/components/ReleaseImpact/ReleaseImpact.tsx @@ -0,0 +1,140 @@ +import { ExternalLink } from 'lucide-react'; +import TableCard from '@/components/TableCard'; +import { + Table, + TableBody, + TableCell, + TableHead, + TableHeader, + TableRow, +} from '@/components/ui/table'; +import { formatDate, formatDelta, formatNumber } from '@/lib/format'; +import { + type ReleaseImpact as Impact, + type ImpactGap, + releaseUrl, + repoName, +} from '@/lib/repos'; +import { cn } from '@/lib/utils'; + +interface ReleaseImpactProps { + impacts: Impact[]; + /** Window length on each side of a release, in days. */ + days: number; + /** Name the repo next to each tag (products with several repos). */ + showRepo?: boolean; +} + +const GAP: Record = { + uncollected: 'before collection began', + filling: 'still filling', +}; + +function Count({ + value, + gap, +}: { + value: number | null; + gap: ImpactGap | null; +}) { + const why = gap ? GAP[gap] : 'unknown'; + return ( + + {value === null ? ( + + — ({why}) + + ) : ( + formatNumber(value) + )} + + ); +} + +/** + * Downloads in the days before each recent stable release against the same + * number of days from its release day, so a release's pull shows as a + * number rather than a bump to eyeball. + */ +function ReleaseImpact({ + impacts, + days, + showRepo = false, +}: ReleaseImpactProps) { + return ( + +
  • + Downloads in the {days} days before each stable release, against the{' '} + {days} days starting on its release day. The page's source and type + filters apply. +
  • +
  • + A dash means that window is not fully known: it starts before every + source was collected, or it has not finished yet. +
  • +
  • + Releases close together share days, so their windows overlap. Read + the change as a hint, not a cause. +
  • + + } + footnote={`${impacts.length === 1 ? 'The newest stable release' : `The ${impacts.length} newest stable releases`} with download data on at least one side.`} + > + + + + Release + Date + {days} days before + {days} days after + Change + + + + {impacts.map( + ({ release: r, before, after, change, beforeGap, afterGap }) => ( + + + + {r.tag} + + {showRepo && ( + + {repoName(r.repo)} + + )} + + + {formatDate(r.date, true)} + + + + + {formatDelta(change)} + + + ), + )} + +
    +
    + ); +} + +export default ReleaseImpact; diff --git a/site/src/components/ReleaseImpact/index.ts b/site/src/components/ReleaseImpact/index.ts new file mode 100644 index 00000000..0d47f092 --- /dev/null +++ b/site/src/components/ReleaseImpact/index.ts @@ -0,0 +1 @@ +export { default } from './ReleaseImpact'; diff --git a/site/src/components/TrendChart/TrendChart.test.tsx b/site/src/components/TrendChart/TrendChart.test.tsx new file mode 100644 index 00000000..25013650 --- /dev/null +++ b/site/src/components/TrendChart/TrendChart.test.tsx @@ -0,0 +1,41 @@ +import { render, screen, within } from '@testing-library/react'; +import TrendChart from './TrendChart'; + +const rows = [ + { date: '2026-10-01', quay: 5 }, + { date: '2026-10-02', quay: 9 }, +]; + +describe('TrendChart', () => { + it('lists releases in the legend and for screen readers', () => { + render( + , + ); + const figure = screen.getByRole('figure', { name: 'Downloads' }); + expect( + within(screen.getByRole('list', { name: 'Legend' })).getByText('Release'), + ).toBeInTheDocument(); + expect(figure).toHaveTextContent('Releases: v1.2.0 (Oct 2, 2026).'); + expect(figure).not.toHaveTextContent('v1.0.0'); + }); + + it('shows no legend for one series without releases', () => { + render( + , + ); + expect(screen.queryByRole('list', { name: 'Legend' })).toBeNull(); + }); +}); diff --git a/site/src/components/TrendChart/TrendChart.tsx b/site/src/components/TrendChart/TrendChart.tsx index ab39d4fa..c3f25677 100644 --- a/site/src/components/TrendChart/TrendChart.tsx +++ b/site/src/components/TrendChart/TrendChart.tsx @@ -1,4 +1,4 @@ -import { Clock, TriangleAlert } from 'lucide-react'; +import { Clock, Tag, TriangleAlert } from 'lucide-react'; import { Area, AreaChart, @@ -20,6 +20,7 @@ import { formatNumber, formatQuarter, } from '@/lib/format'; +import type { ReleaseMark } from '@/lib/repos'; export type Bucket = 'day' | 'week' | 'month' | 'quarter'; @@ -78,6 +79,11 @@ interface TrendChartProps { partialFrom?: string | null; /** Tooltip note on incomplete rows, e.g. which sources are missing. */ partialNote?: string; + /** + * Releases, one mark per row (day, or week's Monday). Drawn as thin lines + * in the primary hue and named in the tooltip. + */ + releases?: ReleaseMark[]; title: string; } @@ -89,17 +95,20 @@ function ChartTooltip({ notes, parts, partial, + released, }: TooltipProps & { bucket: Bucket; notes: Map; parts: Map; partial: ((date: string) => string | null) | null; + released: Map; }) { if (!active || !payload?.length) return null; const items = [...payload].reverse(); // top of the stack first const sum = items.reduce((acc, p) => acc + (p.value ?? 0), 0); const note = notes.get(String(label)); const partialNote = partial?.(String(label)); + const tags = released.get(String(label)); return (

    @@ -142,6 +151,17 @@ function ChartTooltip({

    )} + {tags && ( +

    +

    + )} {partialNote && (

    )} - {(series.length > 1 || partialStart) && ( + {releaseRows.length > 0 && ( +

    + Releases:{' '} + {releaseRows + .map( + (m) => + `${m.tags.join(', ')} (${bucketLabel(m.date, bucket, true)})`, + ) + .join('; ')} + . +

    + )} + {(series.length > 1 || partialStart || releaseRows.length > 0) && (
      ))} + {releaseRows.length > 0 && ( +
    • +
    • + )} {partialStart && (
    • } cursor={{ @@ -309,6 +356,16 @@ function TrendChart({ ifOverflow="hidden" /> )} + {releaseRows.map((m) => ( + + ))} {shown.map((l, i) => ( { it('sums snapshots across repos, carrying each repo forward', () => { @@ -20,3 +26,81 @@ describe('open work', () => { ]); }); }); + +describe('releaseMarks', () => { + const releases = [ + { tag: 'v2', date: '2026-10-08', prerelease: false }, + { tag: 'v1.1', date: '2026-10-06', prerelease: false }, + { tag: 'v1', date: '2026-09-01', prerelease: false }, + ]; + + it('keeps releases in the window, one mark per day', () => { + expect(releaseMarks(releases, '2026-10-01', '2026-10-31')).toEqual([ + { date: '2026-10-06', tags: ['v1.1'] }, + { date: '2026-10-08', tags: ['v2'] }, + ]); + }); + + it('groups by Monday on weekly charts', () => { + // Oct 6 and Oct 8, 2026 are in the week of Monday, Oct 5. + expect(releaseMarks(releases, '2026-08-01', '2026-10-31', true)).toEqual([ + { date: '2026-08-31', tags: ['v1'] }, + { date: '2026-10-05', tags: ['v1.1', 'v2'] }, + ]); + }); +}); + +describe('releaseImpact', () => { + // 10 a day through Oct 10, 20 a day from Oct 11. + const series = Array.from({ length: 40 }, (_, i) => { + const date = new Date(Date.UTC(2026, 8, 20 + i)).toISOString().slice(0, 10); + return { date, count: date >= '2026-10-11' ? 20 : 10 }; + }); + const rel = (tag: string, date: string) => ({ + tag, + date, + prerelease: false, + repo: 'nebari-dev/x', + }); + + it('compares the 14 days before a release with the 14 from its day', () => { + const [impact] = releaseImpact( + [rel('v2', '2026-10-11')], + series, + '2026-09-20', + '2026-10-29', + ); + expect(impact.before).toBe(140); + expect(impact.after).toBe(280); + expect(impact.change).toBeCloseTo(1); + }); + + it('leaves a window unknown before collection began or while filling', () => { + const [early, late] = releaseImpact( + [rel('v3', '2026-10-25'), rel('v1', '2026-09-25')], + series, + '2026-09-20', + '2026-10-29', + ); + // v3's after-window runs to Nov 7, past the last complete day. + expect(early.after).toBeNull(); + expect(early.before).toBe(280); + expect(early.change).toBeNull(); + expect(early.afterGap).toBe('filling'); + // v1's before-window starts Sep 11, before Sep 20. + expect(late.before).toBeNull(); + expect(late.beforeGap).toBe('uncollected'); + expect(late.after).toBe(140); + }); + + it('leaves out releases with neither window known', () => { + expect( + releaseImpact( + [rel('v0', '2026-08-01')], + series, + '2026-09-20', + '2026-10-29', + ), + ).toEqual([]); + }); +}); diff --git a/site/src/lib/repos.ts b/site/src/lib/repos.ts index 20ffb9cd..db602c1c 100644 --- a/site/src/lib/repos.ts +++ b/site/src/lib/repos.ts @@ -12,6 +12,7 @@ import { type Repo, type StarPoint, type TrafficPoint, + weekStart, } from '@/lib/summary'; export function repoUrl(repo: string): string { @@ -24,6 +25,95 @@ export function releaseUrl(repo: string, tag: string): string { // ---- releases ---------------------------------------------------------------- +/** Releases that fall on one chart row (a day, or a week's Monday). */ +export interface ReleaseMark { + date: string; + tags: string[]; +} + +/** + * Chart marks for releases inside [start, end], grouped by chart row: the + * day, or the Monday of its week on weekly charts. Oldest first. + */ +export function releaseMarks( + releases: Release[], + start: string, + end: string, + weekly = false, +): ReleaseMark[] { + const by = new Map(); + for (const r of [...releases].sort((a, b) => a.date.localeCompare(b.date))) { + if (r.date < start || r.date > end) continue; + const date = weekly ? weekStart(r.date) : r.date; + by.set(date, [...(by.get(date) ?? []), r.tag]); + } + return [...by] + .map(([date, tags]) => ({ date, tags })) + .sort((a, b) => a.date.localeCompare(b.date)); +} + +export interface ReleaseImpact { + release: ReleaseWithRepo; + /** Downloads in the `days` days before the release day; null if not all collected. */ + before: number | null; + /** Downloads from the release day on, for `days` days; null if not complete yet. */ + after: number | null; + /** after / before - 1, as a fraction; null when either side is unknown or before is 0. */ + change: number | null; + /** Why `before` / `after` is null. */ + beforeGap: ImpactGap | null; + afterGap: ImpactGap | null; +} + +/** "uncollected": the window starts before every source was collected; "filling": it has not ended. */ +export type ImpactGap = 'uncollected' | 'filling'; + +/** + * Downloads in the window before each release and the same-length window + * starting on its day, newest release first. Releases with neither window + * known are left out. A window that reaches before + * `fullFrom` (the first day every source was collected) or past + * `completeThrough` (the last day every source has reported) is unknown, + * not zero, so a source that started later does not read as growth. + */ +export function releaseImpact( + releases: ReleaseWithRepo[], + series: Point[], + fullFrom: string, + completeThrough: string, + days = 14, + limit = 10, +): ReleaseImpact[] { + const sum = (from: string, to: string) => + series.reduce( + (n, p) => (p.date >= from && p.date <= to ? n + p.count : n), + 0, + ); + const gap = (from: string, to: string): ImpactGap | null => + !fullFrom || from < fullFrom + ? 'uncollected' + : !completeThrough || to > completeThrough + ? 'filling' + : null; + return releases + .map((release) => { + const beforeFrom = addDays(release.date, -days); + const beforeTo = addDays(release.date, -1); + const afterTo = addDays(release.date, days - 1); + const beforeGap = gap(beforeFrom, beforeTo); + const afterGap = gap(release.date, afterTo); + const before = beforeGap ? null : sum(beforeFrom, beforeTo); + const after = afterGap ? null : sum(release.date, afterTo); + const change = + before !== null && after !== null && before > 0 + ? after / before - 1 + : null; + return { release, before, after, change, beforeGap, afterGap }; + }) + .filter((i) => i.before !== null || i.after !== null) + .slice(0, limit); +} + export interface ReleaseWithRepo extends Release { repo: string; } diff --git a/site/src/pages/Product/Product.test.tsx b/site/src/pages/Product/Product.test.tsx index e70810f1..c27d5cd6 100644 --- a/site/src/pages/Product/Product.test.tsx +++ b/site/src/pages/Product/Product.test.tsx @@ -69,6 +69,15 @@ describe('Product', () => { expect(screen.getByText('Latest release')).toBeInTheDocument(); // In the latest-release tile and in the recent releases list. expect(screen.getAllByText('v1.2.0')).toHaveLength(2); + // Only 10 days of downloads: neither 14-day window around v1.2.0 is + // known, so the downloads-around-releases table stays hidden. + expect( + screen.queryByRole('table', { name: /days before and after/ }), + ).not.toBeInTheDocument(); + // The release is still marked on the downloads chart. + expect( + screen.getByRole('figure', { name: /downloads by source/ }), + ).toHaveTextContent(/v1\.2\.0 \(Oct 8, 2026\)/); await userEvent.click( screen.getByRole('button', { name: 'About: Releases, 90 days' }), ); diff --git a/site/src/pages/Product/Product.tsx b/site/src/pages/Product/Product.tsx index 8d8100bf..6cb7af48 100644 --- a/site/src/pages/Product/Product.tsx +++ b/site/src/pages/Product/Product.tsx @@ -4,6 +4,7 @@ import { Link, useLocation, useParams } from 'react-router-dom'; import ChartCard from '@/components/ChartCard'; import Filters from '@/components/Filters'; import PageHeader from '@/components/PageHeader'; +import ReleaseImpact from '@/components/ReleaseImpact'; import SearchBox from '@/components/SearchBox'; import ShareChart from '@/components/ShareChart'; import StatRow from '@/components/StatRow'; @@ -37,6 +38,8 @@ import { laterDate, openWorkSeries, productReleases, + releaseImpact, + releaseMarks, releaseUrl, repoName, repoUrl, @@ -83,6 +86,9 @@ import { } from '@/lib/summary'; import NotFound from '@/pages/NotFound'; +/** Days on each side of a release in the downloads-around-releases table. */ +const IMPACT_DAYS = 14; + interface ReleaseRow { tag: string; cumulative: number; @@ -187,6 +193,20 @@ function useProductView( const stable = productReleases(product); const feed = productReleases(product, { includePrereleases: true }); + // Days every selected source covers, so release windows never compare + // a source's absence with its presence. + let fullFrom = ''; + let completeThrough = ''; + for (const source of SOURCES) { + const own = sumSeries( + artifacts.filter((a) => a.source === source).map((a) => a.series), + ); + const first = own[0]?.date; + const last = own.at(-1)?.date; + if (!first || !last) continue; + if (first > fullFrom) fullFrom = first; + if (!completeThrough || last < completeThrough) completeThrough = last; + } const traffic = trafficRange(product.repos); const trafficStart = traffic ? laterDate(addDays(traffic.end, -13), traffic.start) @@ -302,6 +322,14 @@ function useProductView( allKnown: total(series), chartRows: chartRows(bySource, start, end, weekly), markers: weekly ? [] : markersFor(between(series, start, end)), + releaseMarks: releaseMarks(stable, start, end, weekly), + impacts: releaseImpact( + stable, + series, + fullFrom, + completeThrough, + IMPACT_DAYS, + ), chartSeries, releases: releaseRows(releases), platforms: platformRows(releases), @@ -475,6 +503,10 @@ function Product() { Yellow dots are spike days, usually CI or mirrors. They stay in the totals.
    • +
    • + Thin lines in the primary color are stable releases; hover for + the tag. +
    } @@ -487,11 +519,20 @@ function Product() { lines={coverageLines(view.coverage)} partialFrom={view.coverage.partialFrom} partialNote={partialNote(view.coverage, view.weekly)} + releases={view.releaseMarks} title={`${product.name} downloads by source, ${rangeLabel}`} /> )} + {view.chartSeries.length > 0 && view.impacts.length > 0 && ( + 1} + /> + )} +