From 5c7b3a78f2195c217453eda86818d340332e76c5 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Sat, 27 Jun 2026 22:54:55 +0300 Subject: stats: replace render_kind case with declare -F name dispatch _stats_render_category dispatched on render_kind via a four-arm case (camera|ranked|ordered|month), a modification magnet inconsistent with the codebase's other data-driven dispatch (the STATS_RECORD_FUNCTIONS registry and template.source.sh's prepare_template_render_var__ declare -F lookup). Resolve the per-kind renderer by name instead: dispatch to _stats_render_section__ via `declare -F`, guarded so a missing handler fails loudly (and so set -euo pipefail's errexit does not trip on declare -F's non-zero "absent" status). Rename the three section renderers to the _stats_render_section__{ranked,ordered,month} convention. Fold the camera kind into ranked: the camera leaderboard differed from an ordinary ranked section only by the extra 'stats-leaderboard'
    class -- data, not logic -- so it becomes a 'ranked' entry carrying that class in a new optional 5th spec field (list_class), eliminating the camera special case. Stats body output is byte-identical before/after for every render kind (verified via snapshot diff); the existing stats tests stay green. Co-Authored-By: Claude Opus 4.8 --- src/lib/stats-aggregate.source.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'src/lib/stats-aggregate.source.sh') diff --git a/src/lib/stats-aggregate.source.sh b/src/lib/stats-aggregate.source.sh index 77603c5..24a0687 100644 --- a/src/lib/stats-aggregate.source.sh +++ b/src/lib/stats-aggregate.source.sh @@ -50,20 +50,24 @@ # TEMPLATE_RENDER_FIELD_SPECS) holding everything the generic reset, recording # dispatch and render loops need: # -# count_array|prefix|heading|render_kind +# count_array|prefix|heading|render_kind[|list_class] # # count_array the STATS_* associative array holding this category's counts; # also the array reset_photo_exif_stats clears each run. # prefix the namespace passed to _stats_tally / _stats_filter_link (and # the filter-page slug prefix, e.g. "iso" -> iso-400). # heading the

    shown on the overview (and the per-section title). -# render_kind how the overview renders this category's bars: -# camera - count-desc leaderboard (extra 'stats-leaderboard' -#
      class); only the camera category uses it. -# ranked - count-desc bars (years, lenses, decoded enums). +# render_kind how the overview renders this category's bars; resolved by name +# to a _stats_render_section__ handler (declare -F +# dispatch in stats-render.source.sh): +# ranked - count-desc bars (camera leaderboard, years, lenses, +# decoded enums). # ordered - fixed bucket-ladder order from # STATS_CATEGORY_BUCKETS (apertures wide->narrow, ...). # month - calendar Jan..Dec order with English month names. +# list_class optional extra
        CSS class for the 'ranked' kind. The camera +# leaderboard passes 'stats-leaderboard' (data-only difference, so +# no separate camera render kind); other ranked categories omit it. # # The array order IS the overview/body display order, so it must reproduce the # historical _stats_build_body sequence exactly (camera, year, month, the four @@ -79,7 +83,7 @@ # harness sources the lib via test::source_shuriken_lib); a plain `declare -r` # would be function-local and vanish on return. declare -gra STATS_CATEGORIES=( - 'STATS_CAMERAS|camera|Camera leaderboard|camera' + 'STATS_CAMERAS|camera|Camera leaderboard|ranked|stats-leaderboard' 'STATS_YEARS|year|Photos per year|ranked' 'STATS_MONTHS|month|Photos per month|month' 'STATS_APERTURE|aperture|Aperture|ordered' -- cgit v1.2.3