Skip to content
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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Amazing

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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why no unique?

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,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

unique

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);
Comment on lines +37 to +38
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are we altering it here? We can add the constraint directly during creation

Loading