Skip to content

Playbooks for g

Story-style workflows—solo, team, and on-call. Jump into the full Use cases page anytime.

commands::stats

Usage-statistics report — `g stats`.

auto-generated This page is built from //! comments in the Rust source. Edit the source and run npm run docs:extract to update it.

Usage-statistics report — g stats.

Aggregates data from two sources:

  1. SQLite database (~/.config/g/g.db) — command runs, commits recorded via g commit, branch events, workspace events, stack events.
  2. git log — real commit dates (all branches) for the heatmap, and per-commit line-change counts for the sparkline chart.

Folder layout

stats/
  mod.rs           ← this file: public `stats()` entry point + routing
  shared.rs        ← fmt helpers + the generic horizontal bar chart
  overview.rs      ← Usage Overview section
  heatmap.rs       ← 52-week commit heatmap
  lines_chart.rs   ← +/- lines sparkline (last 60 commits)
  top_commands.rs  ← Top Commands bar chart
  commit_types.rs  ← Conventional-commit type distribution
  repo_activity.rs ← Repository activity ranking
  active_hours.rs  ← Activity-by-hour vertical chart
  messages.rs      ← `--message-stats` mode: length stats, trends, top authors
  import.rs        ← `--import` mode: backfill git history into the db
  search.rs        ← `--search` mode: fuzzy search of imported commits
  duplicates.rs    ← `--duplicates` mode: repeated commit subjects

Each section is its own focused file. Cross-section helpers (number formatting, the generic bar chart) live in [shared] and are pub(super)-scoped — they never leak outside stats/.

Source: src/commands/stats/mod.rs