From 25aff490d739290602b28bdc53936dd3ea6ed939 Mon Sep 17 00:00:00 2001 From: Paul Buetow Date: Wed, 17 Jun 2026 21:35:21 +0300 Subject: mn0 share camera Make+Model dedup helper The rule that joins a camera's EXIF Make + Model into one label while avoiding a duplicated manufacturer prefix (e.g. "Canon Canon EOS 5D" -> "Canon EOS 5D") was implemented independently in the album tooltip builder and the stats leaderboard tally. Extract it into a single shared helper camera_label_from_make_model in the new src/lib/metadata-label.source.sh, sourced before both callers. Both prior implementations were behavior-identical (empty model -> make, empty make -> model, exact/prefix dedup, case-sensitive), so this is a pure DRY refactor with no observable output change. Added a focused unit test covering dedup, plain concatenation and the empty-field edge cases. Co-Authored-By: Claude Opus 4.8 --- src/lib/stats-aggregate.source.sh | 25 ++++--------------------- 1 file changed, 4 insertions(+), 21 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 ebb75cf..46592c4 100644 --- a/src/lib/stats-aggregate.source.sh +++ b/src/lib/stats-aggregate.source.sh @@ -300,34 +300,17 @@ _stats_slug() { printf '%s' "$slug" } -# Join Make + Model into a single camera label, reusing the same dedup logic as -# album.source.sh's tooltip builder (handles "Model already includes Make"). -_stats_camera_label() { - local -r make="$1"; shift - local -r model="$1"; shift - - if [ -z "$model" ]; then - printf '%s' "$make" - return - fi - if [ -z "$make" ]; then - printf '%s' "$model" - return - fi - case "$model" in - "$make"|"$make "*) printf '%s' "$model" ;; - *) printf '%s %s' "$make" "$model" ;; - esac -} - # Tally a photo's camera (Make+Model) and, when present, its lens into their # leaderboard counts and filter mini-albums. Skips photos with no Make/Model. +# The Make+Model dedup now lives in camera_label_from_make_model +# (metadata-label.source.sh, task mn0), shared with the album tooltip builder. _stats_record_camera() { local -n values_ref="$1"; shift local -r photo="$1"; shift local label - label=$(_stats_camera_label "${values_ref[Make]:-}" "${values_ref[Model]:-}") + label=$(camera_label_from_make_model \ + "${values_ref[Make]:-}" "${values_ref[Model]:-}") _stats_tally STATS_CAMERAS camera "$label" "$label" "$photo" if [ -n "${values_ref[LensModel]:-}" ]; then _stats_tally STATS_LENSES lens \ -- cgit v1.2.3