Site administration
Delete the events of one person
A person asks you to delete their analytics events. Delete their events and their rows of the rankings from ClickHouse.
2 min read
You need psql, and neonctl signed in to the Neon organization of the forge. The rows of the forge are in Postgres on Neon (README.md, "Database"). Put the URL of its database in PG_URL. The URL holds a password, so keep it in your shell only:
PG_URL="$(neonctl connection-string main --project-id tiny-unit-38538247 --role-name app --database-name source)"
You need:
- The Source repository with wrangler signed in, on your computer.
- To be signed in to the server as root. See Sign in to the server.
1. Load the files of dead/ first
If dead/ has files, load them first, as Load the batches that never got in shows. A file that you load later brings back the events of the person.
2. Find the user id of the person
On your computer, run:
psql "$PG_URL" -c "SELECT id FROM users WHERE username = '<username>'"
3. Delete their events
On the server, delete their events, and their rows of the rankings:
clickhouse-client --password "$(cat /root/.clickhouse-admin)" --query "DELETE FROM analytics.events WHERE distinct_id = '<user id>'"
clickhouse-client --password "$(cat /root/.clickhouse-admin)" --query "DELETE FROM analytics.rank_actions WHERE person_id = '<user id>'"
The scores of the repositories change at the next run of the ranking cron, in 15 minutes or less. Awards that Source gave before do not change.
Done
Queries stop showing these rows at once. ClickHouse removes them from the disk when it next merges the parts of the table.
Note
The backups keep a copy of these events for up to 9 days. Then the daily work of the web cron deletes the last backup that has them (The nightly backup).