This repository contains utility tools for CorrelAid.
correlaid-analytics
has been updated for a talk in November
2020 but please still proceed with caution
Relevant older versions of this repository: - correlaid-analytics Python / Serverless version
Code to get twitter follower, facebook likes, newsletter subscriber count and general network data on a daily basis using {smcounts}.
Check out the small Github page for some plots. :)
ca_counts <- readr::read_csv("https://raw.githubusercontent.com/friep/correlaid-utils/main/correlaid-analytics/data/all_daily.csv")
install.packages("bspm")
bspm::enable()
install.packages("remotes")
install.packages("cronR")
install.packages("gert") # requires libssl-dev and libgit2-dev (install with sudo apt install)
- install {smcounts} and its dependencies
- copy
.Renviron
with all necessary environment variables and the.slackr
file to thecorrelaid-analytics
folder on the Raspberry Pi. - Copy
rtweet_token.rds
to home directory on Raspberry Pi (setTWITTER_PAT
accordingly in .Renviron) - Run
cron.R
to set up cron job:Rscript path/to/cron.R
. Check withcrontab -l
- add a
GITHUB_PAT
(GitHub Personal Access Token) to.Renviron
. This is needed for the authentication with GitHub.
Every morning at 7am, GitHub Actions run to see whether a commit was
made to the all_daily.csv
file. If not, then the build fails and I’ll
get notified via email about the failed pipeline.
This folder contains the code to automatically send out the welcome email to new subscribers to our newsletter once a day.
All the code resides on a raspberry pi which is located in @friep’s flat. The individual steps are all wrapped in a bash file (runscripts.sh) that executes the scripts in their order. This bash file itself is scheduled to run each night on the raspberry pi using cronjobs.
The scripts are in the order they are executed by runscripts.sh:
- get_new_subs.R: query the Mailchimp API for our newsletter subscriber list and write newly subscribed users to a temporary csv file.
- send_mails.py: read in the temporary file and send out mails to the newly subscribed users by connecting to our mail server.
- send_logs.py: send log files to @friep’s correlaid address.