Skip to content

Leaderboard for Hyperspeedcube solves

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT
Notifications You must be signed in to change notification settings

Hypercubers/hsc-leaderboard

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7ef7df0 · Feb 25, 2025
Feb 14, 2025
Feb 22, 2025
Feb 25, 2025
Feb 23, 2025
Feb 23, 2025
Feb 22, 2025
Feb 25, 2025
Feb 25, 2025
Feb 23, 2025
Feb 25, 2025
Feb 13, 2025
Feb 25, 2025
Feb 23, 2025
Feb 23, 2025
Feb 12, 2025
Feb 12, 2025
Feb 23, 2025
Feb 14, 2025

Repository files navigation

hsc-leaderboard

Combined database + API + web server + Discord bot for the Hypercubing leaderboards

Setup

Development

  1. Install Rust
  2. Clone this repository:
git clone https://github.com/Hypercubers/hsc-leaderboard.git
cd hsc-leaderboard
  1. Follow the database setup instructions
  2. Install sqlx with cargo install sqlx-cli
  • On Ubuntu, you may need to run sudo apt install gcc libssl-dev pkg-config first
  1. Initialize the database schema with cargo sqlx migrate run
  2. (optional) Create a file discord_accounts.txt containing lines of the form name_in_solvers_yml DISCORD_USER_ID
  3. Run cargo run -- reset && cargo run -- init to reinitialize the database from solves.csv
  4. Run cargo run to run the web server and Discord bot

Before committing, run cargo sqlx prepare. To do this automatically on every commit, create a pre-commit hook with this command:

echo "cargo sqlx prepare > /dev/null 2>&1; git add .sqlx > /dev/nu
ll" > .git/hooks/pre-commit && chmod +x .git/hooks/pre-commit

Running (Linux)

  1. Install the GitHub CLI with sudo apt install gh
  2. Create a personal access token, preferably with the Hypercubers organization as the resource owner and a long expiration.
  • Set the resource owner to the Hypercubers organization
  • Set the expiration to 1 year
  • Set the repository access to Public repositories (read-only)
  1. Run gh run download --repo hypercubers/hsc-leaderboard --name linux
  2. Extract the file with unzip linux.zip
  3. Follow the database setup instructions
  4. Intialize the database from solves.csv with ./hsc-leaderboard init

You can use psql -U leaderboards_bot -h 127.0.0.1 leaderboards to access the database directly, although it's best to avoid this. Remember to always BEGIN TRANSACTION before making any changes!

Database setup

  1. Install PostgreSQL
  • On macOS: brew install postgresql
  • On Ubuntu: sudo apt install postgresql-client && sudo systemctl enable --now postgresql
  1. Access the PSQL prompt and use it to set up the database.
  • On macOS: psql -d template1
  • On Linux: sudo -u postgres psql
CREATE DATABASE leaderboards;
CREATE USER leaderboards_bot WITH PASSWORD 'password';
ALTER DATABASE leaderboards OWNER TO leaderboards_bot;
exit
  1. Create a .env file based on .env.example
  • (Optional) Replace leaderboards_bot with the database user you used in step 2
  • (Optional) Replace leaderboards with the database name you used in step 2
  • (Optional) Replace password with the database password you used in step 2
  • Replace YOUR_DISCORD_TOKEN_HERE with your Discord bot token

Documentation

See docs/schema.md for an explanation of the database schema.

License

This project is licensed under MIT OR Apache v2.0.