Saves event stats files from Turbo Sliders Unlimited to a database in a very structured way.
It uses pdm for python library management, sqlalchemy object-relational-mappers and alembic for database change management.
It is made to provide the data for the TSU community website tsura.org.
Thanks to McVizn for the idea, thanks to Ande for replying quickly to all questions I had and thanks to the whole community for being awesome! :)
When you host a dedicated server (more information on dedicated servers in TSU) you can activate that the server should save eventstats.json files. You can see some examples here.
When the next event ends, the file will be overwritten though which is why I placed two files into the config/Scripts/
directory:
- eventend.src with
/cmd move_eventstats.sh
as a one line. When automaticScripts option is activated in the server, this will run automatically when an event ends. move_eventstats.sh
file that moves files into~/eventstats
folder and renames them. You need to make sure that the folder exists and that you havejq
installed cause the script also extracts the track name from the file content, see move_eventstats.sh.
If you want to know which data is saved, have a look at the models.py file. Every single checkpoint time can be saved.
Check Saver.py for the main logic of reading the file and saving them to the database.
Create a .env file and define this variable: TSU_HOTLAPPING_POSTGRES_URL=postgresql://user:password@host/database
Obviously, you can change the variable name when you change it in the scripts as well.
In order to run this, you need to have a database with a "tsu" schema, run alembic migrations and then run models.py.
Some commands to get you up and running quickly (assuming you have pdm and python installed):
pdm run alembic upgrade head
to apply db migrationspdm run alembic revision --autogenerate -m "description what changed int he models"
to generate a alembic migration after you made changes to a modelpdm run python run.py examples/20240323_234957_Interlagosv6.json
to run the script