Mastodon follower tracking (please do not use for unhealthy social media obsession reasons, it's for curiosity/fun only)
SERIOUSLY TAKE IT EASY!
CREATE TABLE snapshot (
id INTEGER PRIMARY KEY ASC,
date TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
api_count INTEGER NOT NULL,
json_count INTEGER NOT NULL,
json TEXT NOT NULL CONSTRAINT is_valid_json CHECK(json_valid(json))
) STRICT;
The STRICT
syntax is relatively new, if it's not recognized in your sqlite3 version, you can just remove it.
Why both api_count
and json_count
? Personally I found them not to agree,
which is what prompted me to track changes in case I can figure out a pattern
that explains it.
Do not directly copy paste this, since it includes the >
line prefix of the Here document.
$ sqlite3 followers.db << 'EOF'
> CREATE TABLE snapshot (
> id INTEGER PRIMARY KEY ASC,
> date TEXT NOT NULL DEFAULT CURRENT_TIMESTAMP,
> api_count INTEGER NOT NULL,
> json_count INTEGER NOT NULL,
> json TEXT NOT NULL CONSTRAINT is_valid_json CHECK(json_valid(json))
> ) STRICT;
> EOF
$
$ crontab -e
append:
# m h dom mon dow command
0 0,12,18 * * * /bin/bash /home/user/.local/bin/mastodon_stats.sh >> /home/user/.local/share/mastodon/run.log