From b9e17e28bd118493b1dc9306cedfb28e4de02d58 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Sun, 25 Apr 2021 13:30:47 -0400 Subject: [PATCH] cleanup: Move jam-tuesday/stats.sh -> bin/jam-stats.sh This in prep for a real jam-tuesday/index.html --- Makefile | 4 ++-- bin/jam-stats.sh | 43 +++++++++++++++++++++++++++++++++++++++++++ jam-tuesday/stats.sh | 42 ------------------------------------------ 3 files changed, 45 insertions(+), 44 deletions(-) create mode 100755 bin/jam-stats.sh delete mode 100755 jam-tuesday/stats.sh diff --git a/Makefile b/Makefile index 3596299..b96a528 100644 --- a/Makefile +++ b/Makefile @@ -25,8 +25,8 @@ index.html: atom.xml: blog.7 bin/genatom.sh ./bin/genatom.sh > $@ -jam-tuesday/greatest-hits: $(SETS) jam-tuesday/stats.sh - (date; echo; ./jam-tuesday/stats.sh) > $@ +jam-tuesday/greatest-hits: $(SETS) bin/jam-stats.sh + (date; echo; ./bin/jam-stats.sh) > $@ bin/kiosk: src/kiosk.c $(CC) $(CFLAGS) -DMANDIR="\"`pwd`\"" src/kiosk.c -o $@ diff --git a/bin/jam-stats.sh b/bin/jam-stats.sh new file mode 100755 index 0000000..d5fe6f0 --- /dev/null +++ b/bin/jam-stats.sh @@ -0,0 +1,43 @@ +#!/bin/sh +# stats.sh -- get frequencies of jam-tuesday songs/artists +set -e + +N=${1:-10} +REPO=$(dirname "$(dirname "$0")") +DIR="$REPO/jam-tuesday" +TMP=$(mktemp) +for set in "$DIR"/[01][0-9]-*; do + # Remove leading notes, blank lines, and instrument/reprise + # comments (and blank lines before or after the comments) + sed '1,/---/d' "$set" | grep -v '^ *$' | sed 's/ *([^)]*) *//g' +done > "$TMP" + +artists() { + sed 's/.*, *//' "$TMP" | sort -f | uniq -i -c +} + +songs() { + sort -f "$TMP" | uniq -i -c +} + +topN() { + sort -n -r | head -n "$N" +} + +echo "Play Stats:" +echo "-----------" +printf "%4d Songs Total\\n" "$(wc -l < "$TMP")" +printf "%4d Unique Songs\\n" "$(songs | wc -l)" +printf "%4d Unique Artists\\n\\n" "$(artists | wc -l)" + +echo "Top $N Artists (Frequency, Name):" +echo "---------------------------------" +artists | topN + +echo "" +echo "Top $N Songs (Frequency, Name):" +echo "-------------------------------" +songs | topN + + +rm "$TMP" diff --git a/jam-tuesday/stats.sh b/jam-tuesday/stats.sh deleted file mode 100755 index f164b37..0000000 --- a/jam-tuesday/stats.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/bin/sh -# stats.sh -- get frequencies of jam-tuesday songs/artists -set -e - -N=${1:-10} -DIR=$(dirname "$0") -TMP=$(mktemp) -for set in "$DIR"/[01][0-9]-*; do - # Remove leading notes, blank lines, and instrument/reprise - # comments (and blank lines before or after the comments) - sed '1,/---/d' "$set" | grep -v '^ *$' | sed 's/ *([^)]*) *//g' -done > "$TMP" - -artists() { - sed 's/.*, *//' "$TMP" | sort -f | uniq -i -c -} - -songs() { - sort -f "$TMP" | uniq -i -c -} - -topN() { - sort -n -r | head -n "$N" -} - -echo "Play Stats:" -echo "-----------" -printf "%4d Songs Total\\n" "$(wc -l < "$TMP")" -printf "%4d Unique Songs\\n" "$(songs | wc -l)" -printf "%4d Unique Artists\\n\\n" "$(artists | wc -l)" - -echo "Top $N Artists (Frequency, Name):" -echo "---------------------------------" -artists | topN - -echo "" -echo "Top $N Songs (Frequency, Name):" -echo "-------------------------------" -songs | topN - - -rm "$TMP" -- libgit2 1.1.1