From c20ec2761ac2d90dc6162a655ff2fe3e6d6df27f Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Thu, 11 Nov 2021 21:17:18 -0500 Subject: [PATCH] jams: Add plaintext rendering of the full archive For gopher! --- Makefile | 2 +- bin/jam-stats.sh | 22 +++++++++++++++++++++- 2 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 24fadb5..484271c 100644 --- a/Makefile +++ b/Makefile @@ -56,7 +56,7 @@ clean: # Individual files to build jam-tuesday/stats: $(SETS) bin/jam-stats.sh - (date; echo; $(DIR)/bin/jam-stats.sh) > $@ + (date; echo; $(DIR)/bin/jam-stats.sh -f) > $@ jam-tuesday/index.html: $(SETS) bin/jam-index.sh bin/jam-stats.sh $(DIR)/bin/jam-index.sh > $@ diff --git a/bin/jam-stats.sh b/bin/jam-stats.sh index b9c81dd..a7b18b6 100755 --- a/bin/jam-stats.sh +++ b/bin/jam-stats.sh @@ -1,8 +1,9 @@ #!/bin/sh # stats.sh -- get frequencies of jam-tuesday songs/artists +# run with -f to show a plaintext table of the "full archive" set -e -N=${1:-10} +N=10 REPO=$(dirname "$(dirname "$0")") DIR="$REPO/jam-tuesday" TMP=$(mktemp) @@ -42,5 +43,24 @@ echo "Top $N Songs (Frequency, Name):" echo "-------------------------------" songs | topN +# TODO: Don't hardcode the width to be perfect (if we ever have more setlists...) +if [ "$1" = "-f" ]; then + printf "\n\n\nFull Archive:\n" + SEP="----------------------------+---------------------------------------+--\n" + sed 's/.*, *//' "$TMP" | sort -u -f | while read artist; do + first="" + grep ", *$artist\$" "$TMP" | sort -f | sed "s#, *$artist *##" | uniq -c -i | \ + while read plays song; do + if [ -z "$first" ]; then + first=1 + printf "$SEP" + printf "%-27s | %-37s |%2d\n" "$artist" "$song" "$plays" + else + printf "%-27s | %-37s |%2d\n" "" "$song" "$plays" + fi + done + done + printf "$SEP" +fi rm "$TMP" -- libgit2 1.1.1