Skip to content
Source
Sign inSign up

Apply the rank rollup

Site administration

Apply the rank rollup to a running server

Your analytics server was set up before the schema had the table of the repository rankings, so the rankings have no data. Add the table before you deploy the rankings, so they count from the first day.

1 min read

You need:

  • The Source repository on your computer.
  • To be signed in to the server as root. See Sign in to the server.

1. Copy the schema to the server

On your computer, run:

scp apps/web/clickhouse/schema.sql root@<server IPv4>:/root/schema.sql

2. Apply the schema

On the server, apply the schema as the admin user default. The user reader is read-only and cannot do it. Each statement is safe to run again, so the table events and its rows do not change:

clickhouse-client --password "$(cat /root/.clickhouse-admin)" --queries-file /root/schema.sql

This creates the table analytics.rank_actions and the view analytics.rank_actions_mv, and gives reader access to read the table.

3. Make sure that reader can read the table

The output has a line with GRANT SELECT ON analytics.rank_actions TO reader:

clickhouse-client --password "$(cat /root/.clickhouse-admin)" --query "SHOW GRANTS FOR reader"

Done

Each new event that counts now goes into analytics.rank_actions, so the repository rankings get their data.

Note

The view copies only the events that arrive after it exists. The events that are already in analytics.events do not get into the rankings.