1 This is the source for **xonstatdb**, the [Xonotic][xonotic] [Statistics database][xonstat].
2 All code herein is intended for the PostgreSQL database management server.
6 To build, first create the user that will own all of the objects in the database.
7 You must run this as an administrator user in your cluster.
8 See your operating system's guidelines for how this is set up on your system.
10 create user xonstat with password 'xonstat';
12 *Note: please change this password*
14 Or from the commandline:
16 # su - postgres (as root)
17 postgres$ createuser -P xonstat (this will prompt you for the users password)
19 Next, create the database itself:
24 CREATE DATABASE xonstatdb
31 Next, as your regular system user, log into the newly created database
32 using the user account you just created.
33 Do this from the root directory of your project checkout.
35 $ psql -U xonstat xonstatdb
37 You might need to force postgres to not use ident, if you get an error
38 like *Peer authentication failed for user "xonstat"*:
40 $ psql -h localhost -U xonstat xonstatdb
42 Create the schema in which all of the xonstat tables will reside:
47 AUTHORIZATION xonstat;
49 Create the plpgsql language, if it doesn't exist:
51 CREATE LANGUAGE plpgsql;
53 Now load the initial tables:
55 \i build/build_full.sql
57 *Note: You will see a lot of NOTICE messages. This is normal.*
61 Do note that there are a few maintenance scripts that can be used
62 once the database begins accumulating data. These can be found in
63 the scripts subdirectory. A summary of what they do follows:
65 update\_elos.sql - will decrease player elo records by one point
66 day for every day after 30 days of inactivity
67 until they hit the elo "floor" of 100. This
68 prevents inactive players from staying on the
69 leaderboard/ranks for too long.
71 update\_ranks.sql - will populate the player\_ranks table each day
72 according to the elo values when it is run.
74 There is also a "merge players" function in the functions sub-
75 directory. This can be used to merge two players together into one
76 record in the presentation layer of XonStat. It can be run as follows:
78 select merge\_players(winner\_player\_id, loser\_player\_id);
80 The "winner" player ID is the account that remains active after the
85 [xonotic]: http://www.xonotic.org/
86 [xonstat]: http://stats.xonotic.org/
90 Project is licensed GPLv3.