Skip to content

Conversation

AadarshM07
Copy link

This adds the necessary queries and mutations required for the cp leaderboard . It includes:

  • Schema definitions for leaderboard data
  • Structs to represent leaderboard entries
  • Mutations to add or update CP handles and unified leaderboard
  • Queries to fetch leaderboard information

All functionalities have been tested using the GraphiQL playground

@ivinjabraham
Copy link
Member

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/.

@ivinjabraham
Copy link
Member

Rewrite the commits and fix the failing workflow and you're good to go.

@AadarshM07
Copy link
Author

@ivinjabraham ok thanks👍

@AadarshM07 AadarshM07 force-pushed the master branch 2 times, most recently from 02b2cd0 to 9ca8e7e Compare July 16, 2025 06:07
@AadarshM07
Copy link
Author

@ivinjabraham I have updated the PR with the requested changes

@@ -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


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?


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

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

Copy link
Member

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

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

Comment on lines +93 to +97
Ok(_) => {
println!("LeetCode stats updated for member ID: {}", member.member_id)
}
Err(e) => eprintln!(
"Failed to update LeetCode stats for member ID {}: {:?}",
Copy link
Member

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

Comment on lines +122 to +128
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
Copy link
Member

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

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

Copy link
Member

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants