From aca23d3a094cb1bf86db40e42f184fbf88371d42 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Tue, 16 Jun 2026 22:14:26 +0300 Subject: cn0 split stats.source.sh into aggregate/render/filter-album modules Pure code move: split the ~1248-line stats.source.sh (SRP+SoC) into three cohesive modules, all functions and STATS_* constants/globals moved verbatim: - stats-aggregate.source.sh: EXIF parsing, bucketing, _stats_tally, reset/collect_photo_exif_stats and the STATS_* maps. - stats-render.source.sh: stats overview page (sections, bars, leaderboard, render_stats_page, _stats_build_body, _stats_filter_link, background pickers). - stats-filter-album.source.sh: per-filter mini-albums (render_filter_pages, gallery/view/thumbnail builders, _stats_enqueue_filter_album). Updated LIB_SOURCES accordingly. No logic change (verified: all 55 functions and top-level globals preserved; full suite, shellcheck, check-generated, diff all pass). The SoC point (HTML built in bash rather than templates) is left for a follow-up (nn0/qn0). Co-Authored-By: Claude Opus 4.8 --- src/lib/stats-aggregate.source.sh | 602 ++++++++++++++++ src/lib/stats-filter-album.source.sh | 265 ++++++++ src/lib/stats-render.source.sh | 396 +++++++++++ src/lib/stats.source.sh | 1248 ---------------------------------- 4 files changed, 1263 insertions(+), 1248 deletions(-) create mode 100644 src/lib/stats-aggregate.source.sh create mode 100644 src/lib/stats-filter-album.source.sh create mode 100644 src/lib/stats-render.source.sh delete mode 100644 src/lib/stats.source.sh (limited to 'src/lib') diff --git a/src/lib/stats-aggregate.source.sh b/src/lib/stats-aggregate.source.sh new file mode 100644 index 0000000..ebb75cf --- /dev/null +++ b/src/lib/stats-aggregate.source.sh @@ -0,0 +1,602 @@ +# Stats aggregation for the album stats page (feature plan: +# /home/paul/.pi/plans/shuriken-stats-site.md, field audit: +# docs/stats-exif-audit.md). This module turns the per-photo +# `identify -verbose` output that album.source.sh already caches into +# aggregated, photographer-friendly counters. +# +# Scope: aggregation only. Rendering (stats.tmpl / camera.tmpl) lives in the +# sibling tasks pm0/rm0/um0; this module just fills the data structures they +# read. +# +# ---------------------------------------------------------------------------- +# Public API / handoff contract +# ---------------------------------------------------------------------------- +# collect_photo_exif_stats iterates the album's photos and fills these globals +# (all declared with `declare -gA` so the render tasks can read them after the +# call without namerefs): +# +# STATS_CAMERAS[] = count (camera leaderboard) +# STATS_LENSES[] = count (sparse; may be empty) +# STATS_YEARS[] = count +# STATS_MONTHS[<01..12>] = count +# STATS_APERTURE[] = count (e.g. "f/2.8") +# STATS_SHUTTER[] = count (e.g. "1/250s") +# STATS_ISO[] = count (e.g. "400") +# STATS_FOCAL[] = count (e.g. "35-70mm") +# STATS_MEGAPIXELS[] = count (e.g. "10-20MP") +# STATS_ASPECT[] = count (e.g. "3:2") +# STATS_ORIENTATION[] = count (Landscape/Portrait/Square) +# STATS_FORMAT[] = count (JPEG/PNG/WEBP/GIF) +# STATS_EXPOSURE_PROGRAM[