project_stats.ts

Types and pure helpers for project commit-activity stats.

The committed dataset (project_stats_data.ts, written by the project_stats_update task) stores daily commit counts per project as the master granularity; coarser scopes like monthly are derived at runtime by rebucketing. All date handling is UTC — YYYY-MM-DD strings and "epoch days" (days since the Unix epoch) — so results are deterministic across machines.

view source

Declarations
#

12 declarations

daily_counts_from_timestamps
#

project_stats.ts view source

(timestamps: number[], end_date: string): { start_date: string; daily_counts: number[]; } | null import {daily_counts_from_timestamps} from '@fuzdev/fuz_ui/project_stats.js';

Buckets commit timestamps into daily counts from the earliest commit's UTC day through end_date, inclusive.

timestamps

commit times as Unix epoch seconds

type number[]

end_date

UTC date (YYYY-MM-DD) of the final bucket; later timestamps clamp into it

type string

returns

{ start_date: string; daily_counts: number[]; } | null

the start date and daily counts, or null if timestamps is empty

daily_counts_pad_start
#

project_stats.ts view source

(daily_counts: number[], start_date: string, padded_start_date: string): number[] import {daily_counts_pad_start} from '@fuzdev/fuz_ui/project_stats.js';

Pads daily_counts with leading zeros so the series starts at padded_start_date instead of start_date.

Returns the input array unchanged when padded_start_date is not earlier than start_date.

daily_counts

type number[]

start_date

type string

padded_start_date

type string

returns

number[]

date_from_epoch_day
#

project_stats.ts view source

(epoch_day: number): string import {date_from_epoch_day} from '@fuzdev/fuz_ui/project_stats.js';

Converts days since the Unix epoch to a UTC YYYY-MM-DD date.

epoch_day

type number

returns

string

epoch_day_from_date
#

project_stats.ts view source

(date: string): number import {epoch_day_from_date} from '@fuzdev/fuz_ui/project_stats.js';

Converts a UTC YYYY-MM-DD date to days since the Unix epoch.

date

type string

returns

number

monthly_counts_from_daily
#

project_stats.ts view source

(daily_counts: number[], start_date: string): number[] import {monthly_counts_from_daily} from '@fuzdev/fuz_ui/project_stats.js';

Rebuckets daily counts into calendar-month (UTC) counts.

The first and last buckets may cover partial months.

daily_counts

type number[]

start_date

type string

returns

number[]

project_stats_label
#

project_stats.ts view source

(project: ProjectCommitStats): string import {project_stats_label} from '@fuzdev/fuz_ui/project_stats.js';

Formats a one-line human-readable summary of a project's commit stats, e.g. "gro — 2,386 commits since August 7, 2019". Used for accessible labels and tooltips.

project

returns

string

project_stats_to_monthly_series
#

project_stats.ts view source

(snapshot: ProjectStatsSnapshot): { series: ProjectStatsSeries[]; max: number; } import {project_stats_to_monthly_series} from '@fuzdev/fuz_ui/project_stats.js';

Derives aligned monthly series for every project in snapshot, sharing one time window and one scale.

Each series spans from the earliest project's start_date through the snapshot's end_date (younger projects are zero-padded at the front), so all series have the same length and bucket boundaries. max is the largest monthly count across all projects, for rendering every series at the same vertical scale.

snapshot

returns

{ series: ProjectStatsSeries[]; max: number; }

project_stats_to_weekly_series
#

project_stats.ts view source

(snapshot: ProjectStatsSnapshot): { series: ProjectStatsSeries[]; max: number; } import {project_stats_to_weekly_series} from '@fuzdev/fuz_ui/project_stats.js';

Derives aligned weekly series for every project in snapshot, sharing one time window and one scale — the weekly sibling of project_stats_to_monthly_series.

snapshot

returns

{ series: ProjectStatsSeries[]; max: number; }

ProjectCommitStats
#

project_stats.ts view source

ProjectCommitStats import type {ProjectCommitStats} from '@fuzdev/fuz_ui/project_stats.js';

Daily commit counts for one project.

name

Project name, matching project_items.

type string

start_date

UTC date (YYYY-MM-DD) of the first day bucket, the day of the first commit.

type string

daily_counts

Commits per UTC day from start_date through the snapshot's end_date, inclusive.

type number[]

ProjectStatsSeries
#

project_stats.ts view source

ProjectStatsSeries import type {ProjectStatsSeries} from '@fuzdev/fuz_ui/project_stats.js';

A derived series of bucketed counts for one project.

name

type string

counts

type number[]

ProjectStatsSnapshot
#

project_stats.ts view source

ProjectStatsSnapshot import type {ProjectStatsSnapshot} from '@fuzdev/fuz_ui/project_stats.js';

A snapshot of commit stats across projects, sharing a single end_date.

generated_at

ISO datetime when the snapshot was collected.

type string

end_date

UTC date (YYYY-MM-DD) of the final day bucket, shared by every project.

type string

projects

type ProjectCommitStats[]

weekly_counts_from_daily
#

project_stats.ts view source

(daily_counts: number[]): number[] import {weekly_counts_from_daily} from '@fuzdev/fuz_ui/project_stats.js';

Rebuckets daily counts into 7-day counts, anchored at the end of the series so the newest bucket always covers a full 7 days.

The first bucket may cover fewer days when the length isn't a multiple of 7.

daily_counts

type number[]

returns

number[]

Imported by
#