]> git.madduck.net Git - code/twitter-archiver.git/blob - report_followers.sh

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

README updates
[code/twitter-archiver.git] / report_followers.sh
1 #!/bin/sh
2 #
3 # reportfollowers.sh
4 #
5 # Send a diff of the follower dumps stored under ./followers per mail,
6 # designed to be run daily from cron.
7 #
8 # The optional argument overrides the timestamp to compare against, which
9 # defaults to "yesterday"
10 #
11 # Copyright © 2017–2019 by martin f. krafft <madduck@madduck.net>
12 # Released under the Artistic Licence 2.0
13 #
14
15 set -eu
16
17 MYDIR="${0%/*}"
18 cd "$MYDIR"/followers
19
20 export LC_ALL=$(locale -a | grep utf8 | head -1)
21
22 REVSPEC="${1:-master@{yesterday\}}"
23 DATESTAMP="$(git show --pretty=format:'%ai (%ar)' --no-patch $REVSPEC)"
24 COUNT=$(wc -l dump | cut -d' ' -f1)
25 STATS="$(git diff --numstat $REVSPEC | \
26   sed -re 's,([[:digit:]]+)[[:space:]]+([[:digit:]]+).*,+\1/-\2,')"
27
28 SENDMAIL="/usr/sbin/sendmail madduck@madduck.net"
29 [ ! -t 0 ] || SENDMAIL=cat
30
31 $SENDMAIL <<_eof
32 From: Twitter follower report <madduck@madduck.net>
33 Subject: $(wc -l dump | cut -d' ' -f1) followers ($STATS)
34
35 Changes since $DATESTAMP:
36
37 $(git diff $REVSPEC | grep '^[-+][^-+]' | sort -k1.1,1.1)
38
39 =Total followers: $COUNT
40 _eof