No description
  • Python 99.6%
  • Dockerfile 0.4%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Neil Johnson 0eab07c7b0
Neilj/elementx (#25)
Support element x cohorts.
2023-08-29 17:31:49 +01:00
.github/workflows Bump up Python to 3.9 and make it the same in unit tests and production (#22) 2021-09-15 10:12:49 +01:00
db_stats Fix gitignore, remove mistakenly committed venv 2021-02-01 15:41:54 +00:00
github_stats Write the results to the stats db 2018-12-07 17:50:32 +00:00
retention Neilj/elementx (#25) 2023-08-29 17:31:49 +01:00
.gitignore Fix gitignore, remove mistakenly committed venv 2021-02-01 15:41:54 +00:00
README.md Add GitHub Actions-based CI to run unit tests (#19) 2021-08-11 10:22:15 +01:00

stats

Retention

To run we need:

  • Postgres DB with synapse's schema
  • MySQL with retention/schema.sql

When testing locally we assume you've got a Postgres Docker container running on the synapse network with an alias of synapse-db. To populate the DB it is probably sensible to run synapse against it.

To create a MySQL container (from the retention sub-directory):

docker run --name stats-db -e MYSQL_RANDOM_ROOT_PASSWORD=yes -e MYSQL_DATABASE=stats -e MYSQL_USER=stats -e MYSQL_PASSWORD=stats -v "$(pwd)/schema.sql:/docker-entrypoint-initdb.d/schema.sql" --network synapse --network-alias stats-db -d mysql:5

Create a .env containing (for example):

SYNAPSE_DB_HOST=synapse-db
SYNAPSE_DB_USERNAME=postgres
SYNAPSE_DB_PASSWORD=
SYNAPSE_DB_DATABASE=synapse
SYNAPSE_DB_OPTIONS=
STATS_DB_HOST=stats-db
STATS_DB_USERNAME=stats
STATS_DB_PASSWORD=stats
STATS_DB_DATABASE=stats

To then run the cohort analysis script:

docker build -t cohort_analysis .
docker run -it --env-file .env --network synapse --network-alias cohort-analysis --rm cohort_analysis <ARGS>

Unit tests

DO NOT run the unit tests against a real Synapse database. The unit tests will create their own tables, deleting existing ones first if necessary.