From f9ab7770085df892da241ae1392b53d3e88b7165 Mon Sep 17 00:00:00 2001 From: Ant Zucaro Date: Mon, 27 May 2024 14:53:42 -0400 Subject: [PATCH] Update README, set perms. --- README.md | 72 ++++++++++++++-------------- queries/identify_bad_rank_games.sql | 0 queries/player_retention_3months.sql | 0 queries/show_elo_rot.sql | 0 queries/win_ratio_by_player_id.sql | 0 5 files changed, 37 insertions(+), 35 deletions(-) mode change 100644 => 100755 queries/identify_bad_rank_games.sql mode change 100644 => 100755 queries/player_retention_3months.sql mode change 100644 => 100755 queries/show_elo_rot.sql mode change 100644 => 100755 queries/win_ratio_by_player_id.sql diff --git a/README.md b/README.md index c18762f..c451ab9 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,17 @@ -This is the source for **xonstatdb**, the [Xonotic][xonotic] [Statistics database][xonstat]. +# XonStatDB + +This is the source for the database underlying [XonStat][xonstat], the statistics application for the arena-style FPS [Xonotic][xonotic]. All code herein is intended for the PostgreSQL database management server. ----- +## Clone + +``` +git clone git@gitlab.com:xonotic/xonstatdb.git +``` -To build, first create the user that will own all of the objects in the database. +## Prepare + +Prepare the database by first creating the user that will own all of the objects in the database. You must run this as an administrator user in your cluster. See your operating system's guidelines for how this is set up on your system. @@ -46,56 +54,50 @@ like *Peer authentication failed for user "xonstat"*: $ psql -h localhost -U xonstat xonstatdb -Create the schema in which all of the xonstat tables will reside: - - xonstatdb=> - - CREATE SCHEMA xonstat - AUTHORIZATION xonstat; Create the plpgsql language, if it doesn't exist: CREATE LANGUAGE plpgsql; -Now load the initial tables: +## Initialize - \i build/build_full.sql +Initial schema setup and subsequent migrations for XonStatDB are handled using [goose][goose]. You may want to familiarize yourself with that tool before proceeding. - *Note: You will see a lot of NOTICE messages. This is normal.* +``` +goose postgres "user=xonstat host=localhost dbname=xonstatdb sslmode=disable password=$PASSWORD" up +``` -And that's it! +That's it! -Do note that there are a few maintenance scripts that can be used +## Maintenance Scripts + +There are a few maintenance scripts that can be used once the database begins accumulating data. These can be found in -the scripts subdirectory and are intended to be implemented as cron jobs. +the scripts subdirectory and are intended to be implemented as cron jobs. + A summary of what they do follows: - update\_elos.sql - will decrease player elo records by one point - day for every day after 30 days of inactivity - until they hit the elo "floor" of 100. This - prevents inactive players from staying on the - leaderboard/ranks for too long. - - update\_ranks.sql - will populate the player\_ranks table each day - according to the elo values when it is run. - - refresh\_$TABLE\_mv.sql - updates the "materialized view" named by $TABLE. - - purge\_anticheat\_log.sql - deletes old anticheat data. - -There is also a "merge players" function in the functions sub- -directory. This can be used to merge two players together into one -record in the presentation layer of XonStat. It can be run as follows: +- refresh_*.sh: refreshes data in various materialized views +- purge_anticheat_log.sh: prunes the anticheat signal data - select merge\_players(winner\_player\_id, loser\_player\_id); +An example crontab using these: +``` +# refresh the materialized views in xonstatdb +00 07 * * * ~/bin/refresh_summary_stats.sh +10 07 * * * ~/bin/refresh_active_players.sh +15 07 * * * ~/bin/refresh_active_servers.sh +20 07 * * * ~/bin/refresh_active_maps.sh +25 07 * * * ~/bin/refresh_recent_game_stats.sh -The "winner" player ID is the account that remains active after the -transaction. +# prune the anticheats +20 08 * * * ~/bin/purge_anticheat_log.sh +``` -Enjoy! + [xonotic]: http://www.xonotic.org/ [xonstat]: http://stats.xonotic.org/ +[goose]: https://github.com/pressly/goose ---- diff --git a/queries/identify_bad_rank_games.sql b/queries/identify_bad_rank_games.sql old mode 100644 new mode 100755 diff --git a/queries/player_retention_3months.sql b/queries/player_retention_3months.sql old mode 100644 new mode 100755 diff --git a/queries/show_elo_rot.sql b/queries/show_elo_rot.sql old mode 100644 new mode 100755 diff --git a/queries/win_ratio_by_player_id.sql b/queries/win_ratio_by_player_id.sql old mode 100644 new mode 100755 -- 2.39.2