Calculate and plot meme production rate - bitreich-memestats - Bitreich meme statistics and graphs. HTML git clone git://bitreich.org/bitreich-memestats git://hg6vgqziawt5s4dj.onion/bitreich-memestats DIR Log DIR Files DIR Refs DIR Tags DIR LICENSE --- DIR commit f80a953430c2244a2c307a6424d1921ad9509644 DIR parent 5bfeec49a9374801c59c6f8d46c423d7d019e806 HTML Author: Anders Damsgaard <anders@adamsgaard.dk> Date: Tue, 21 Apr 2020 22:54:13 +0200 Calculate and plot meme production rate Diffstat: M extract-memecount.sh | 30 +++++++++++++++++++++++++----- M plot-memecount.sh | 17 +++++++++++++++-- 2 files changed, 40 insertions(+), 7 deletions(-) --- DIR diff --git a/extract-memecount.sh b/extract-memecount.sh @@ -15,21 +15,41 @@ if [ "$update_annna" = "yes" ]; then git pull >/dev/null 2>&1 fi +i=0 # derived from Hiltjo Posthuma's loc.sh -git log --pretty='format:%H %cd' --date="format:%Y-%m-%d" | \ +git log --pretty='format:%H %cd %at' --date="format:%Y-%m-%d" | \ sort -k 2 | uniq -f 1 | \ - while read -r commit date; do + while read -r commit date timestamp; do # hashtags originally stored in annna-start-services... n="$(git show "$commit:annna-start-services" 2>/dev/null | \ - grep -E '^ #[a-z0-9]' | wc -l)" + grep -E '^ #[a-z0-9]' | wc -l | awk '{print $1}')" # ...but are now stored in $memefile if [ "$n" -eq 0 ]; then - n="$(git show "$commit:$memefile" 2>/dev/null | wc -l)" + n="$(git show "$commit:$memefile" 2>/dev/null | wc -l | awk '{print $1}')" fi if [ "$n" -gt 1 ]; then - printf '%s\t%s\t%s\n' "$date" "$commit" "$n" + + # only one row per day + if [ "$date" != "$lastprintdate" ]; then + + if [ "$i" -eq 1 ]; then + dn_dt="$(awk \ + -v n0="$n0" -v t0="$t0" -v n="$n" -v t="$timestamp" \ + 'BEGIN{print (n-n0)/(t-t0)*3600.0*24.0}')" + else + dn_dt=0 + i=1 + fi + n0="$n" + t0="$timestamp" + lastprintdate="$date" + + printf '%s\t%s\t%s\t%s\t%s\n' \ + "$date" "$commit" "$n" "$timestamp" "$dn_dt" + + fi fi done DIR diff --git a/plot-memecount.sh b/plot-memecount.sh @@ -11,11 +11,24 @@ fi gnuplot - <<__EOF__ set term dumb set title "annna meme count (total on $(date +%Y-%m-%d): \ -$(tail -1 "$1" | awk '{print $3}')) $semilog" +$(awk 'END{print $3}' "$1")) $semilog" set xdata time set format x "%Y-%m" -set timefmt "%Y-%m-%dT%H:%M:%S" +set timefmt "%Y-%m-%d" set xtics 2592000*4 $semilog plot '$1' u 1:3 w lp t '' pt 13 __EOF__ + +if [ -z "$semilog" ]; then + gnuplot - <<__EOF__ +reset +set term dumb +set title "annna meme growth (new memes per day)" +set xdata time +set format x "%Y-%m" +#set timefmt "%Y-%m-%d" +set xtics 2592000*4 +plot '$1' u 1:5 w lp t '' pt 13 +__EOF__ +fi