-
Notifications
You must be signed in to change notification settings - Fork 18
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
base: develop
Are you sure you want to change the base?
Conversation
Your commit messages could use some work; refer https://www.conventionalcommits.org/en/v1.0.0/ and https://www.simplethread.com/what-makes-a-good-git-commit/. |
Rewrite the commits and fix the failing workflow and you're good to go. |
@ivinjabraham ok thanks👍 |
02b2cd0
to
9ca8e7e
Compare
@ivinjabraham I have updated the PR with the requested changes |
@@ -5,3 +5,4 @@ Secrets*.toml | |||
backups/ | |||
.env | |||
*.log | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amazing
|
||
CREATE TABLE IF NOT EXISTS leetcode_stats ( | ||
id SERIAL PRIMARY KEY, | ||
member_id INT NOT NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why no unique?
|
||
CREATE TABLE IF NOT EXISTS codeforces_stats ( | ||
id SERIAL PRIMARY KEY, | ||
member_id INT NOT NULL, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unique
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); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
L
Ok(members) => { | ||
for member in members { | ||
// Fetch LeetCode username | ||
let leetcode_username = sqlx::query_as::<_, LeetCodeStats>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the variable name, the SQL will return an entire row from the leetcode table
Ok(_) => { | ||
println!("LeetCode stats updated for member ID: {}", member.member_id) | ||
} | ||
Err(e) => eprintln!( | ||
"Failed to update LeetCode stats for member ID {}: {:?}", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migrate from print statements to the tracing/logging library
Ok(_) => println!( | ||
"Codeforces stats updated for member ID: {}", | ||
member.member_id | ||
), | ||
Err(e) => eprintln!( | ||
"Failed to update Codeforces stats for member ID {}: {:?}", | ||
member.member_id, e |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Migrate from print statements to the tracing/logging library
} | ||
|
||
// Fetch Codeforces username | ||
let codeforces_username = sqlx::query_as::<_, CodeforcesStats>( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change the variable name, the SQL will return an entire row from the codeforces table
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move this out of mutations
This adds the necessary queries and mutations required for the cp leaderboard . It includes:
All functionalities have been tested using the GraphiQL playground