Skip to content

Added cp leaderboard queries and mutations #97

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ Secrets*.toml
backups/
.env
*.log

63 changes: 53 additions & 10 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ edition = "2021"
[dependencies]
async-graphql = { version = "7.0.15", features = ["chrono"] }
async-graphql-axum = "7.0.6"
async-graphql-parser = "2.0"
axum = "0.8.1"
chrono = { version = "0.4.38", features = ["clock"] }
serde = { version = "1.0.188", features = ["derive"] }
Expand Down
38 changes: 38 additions & 0 deletions migrations/20250312124630_add_leaderboard_tables.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
-- Add migration script here

CREATE TABLE IF NOT EXISTS leaderboard (
id SERIAL PRIMARY KEY,
member_id INT UNIQUE NOT NULL,
leetcode_score INT,
codeforces_score INT,
unified_score INT NOT NULL,
last_updated TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
FOREIGN KEY (member_id) REFERENCES member(member_id)
);

CREATE TABLE IF NOT EXISTS leetcode_stats (
id SERIAL PRIMARY KEY,
member_id INT NOT NULL,
leetcode_username VARCHAR(255) NOT NULL,
problems_solved INT NOT NULL,
easy_solved INT NOT NULL,
medium_solved INT NOT NULL,
hard_solved INT NOT NULL,
contests_participated INT NOT NULL,
best_rank INT NOT NULL,
total_contests INT NOT NULL,
FOREIGN KEY (member_id) REFERENCES member(member_id)
);

CREATE TABLE IF NOT EXISTS codeforces_stats (
id SERIAL PRIMARY KEY,
member_id INT NOT NULL,
codeforces_handle VARCHAR(255) NOT NULL,
codeforces_rating INT NOT NULL,
max_rating INT NOT NULL,
contests_participated INT NOT NULL,
FOREIGN KEY (member_id) REFERENCES member(member_id)
);

ALTER TABLE leetcode_stats ADD CONSTRAINT leetcode_stats_member_id_key UNIQUE (member_id);
ALTER TABLE codeforces_stats ADD CONSTRAINT codeforces_stats_member_id_key UNIQUE (member_id);
Loading
Loading