diff --git a/server/.sqlx/query-4311e3c06d78c4e89d02f37dc509c022d556434529f8f340ac230a9c5e8e354c.json b/server/.sqlx/query-5c9c5c0c4116a9b18fb2b981cda5a55b929a4219f9ec80f4f5c231f2e7a55596.json similarity index 65% rename from server/.sqlx/query-4311e3c06d78c4e89d02f37dc509c022d556434529f8f340ac230a9c5e8e354c.json rename to server/.sqlx/query-5c9c5c0c4116a9b18fb2b981cda5a55b929a4219f9ec80f4f5c231f2e7a55596.json index b4b77d8..e22b85d 100644 --- a/server/.sqlx/query-4311e3c06d78c4e89d02f37dc509c022d556434529f8f340ac230a9c5e8e354c.json +++ b/server/.sqlx/query-5c9c5c0c4116a9b18fb2b981cda5a55b929a4219f9ec80f4f5c231f2e7a55596.json @@ -1,6 +1,6 @@ { "db_name": "PostgreSQL", - "query": "SELECT\n users.login,\n users.full_name,\n period_type,\n total_score,\n executed_prs,\n largest_score,\n prs_opened,\n prs_merged,\n weekly_streak.best as weekly_streak_best,\n weekly_streak.amount as weekly_streak_amount,\n weekly_streak.latest_time_string as weekly_streak_latest_time_string,\n monthly_streak.best as monthly_streak_best,\n monthly_streak.amount as monthly_streak_amount,\n monthly_streak.latest_time_string as monthly_streak_latest_time_string,\n user_period_data.total_rating as total_rating,\n RANK() OVER (\n ORDER BY\n total_rating DESC\n ) as place,\n users.permanent_bonus as permanent_bonus\nFROM\n user_period_data\n JOIN users ON users.id = user_period_data.user_id\n JOIN streak_user_data AS weekly_streak ON weekly_streak.user_id = users.id\n AND weekly_streak.streak_id = 0\n JOIN streak_user_data AS monthly_streak ON monthly_streak.user_id = users.id\n AND monthly_streak.streak_id = 1\nWHERE\n period_type = $1\n and total_rating > 0\nORDER BY\n place,\n total_rating DESC\nLIMIT\n $2 OFFSET $3\n", + "query": "SELECT\n users.login,\n users.full_name,\n period_type,\n total_score,\n executed_prs,\n largest_score,\n prs_opened,\n prs_merged,\n prs_scored,\n weekly_streak.best as weekly_streak_best,\n weekly_streak.amount as weekly_streak_amount,\n weekly_streak.latest_time_string as weekly_streak_latest_time_string,\n monthly_streak.best as monthly_streak_best,\n monthly_streak.amount as monthly_streak_amount,\n monthly_streak.latest_time_string as monthly_streak_latest_time_string,\n user_period_data.total_rating as total_rating,\n RANK() OVER (\n ORDER BY\n total_rating DESC\n ) as place,\n users.permanent_bonus as permanent_bonus\nFROM\n user_period_data\n JOIN users ON users.id = user_period_data.user_id\n JOIN streak_user_data AS weekly_streak ON weekly_streak.user_id = users.id\n AND weekly_streak.streak_id = 0\n JOIN streak_user_data AS monthly_streak ON monthly_streak.user_id = users.id\n AND monthly_streak.streak_id = 1\nWHERE\n period_type = $1\n and total_rating > 0\nORDER BY\n place,\n total_rating DESC\nLIMIT\n $2 OFFSET $3\n", "describe": { "columns": [ { @@ -45,46 +45,51 @@ }, { "ordinal": 8, - "name": "weekly_streak_best", + "name": "prs_scored", "type_info": "Int4" }, { "ordinal": 9, - "name": "weekly_streak_amount", + "name": "weekly_streak_best", "type_info": "Int4" }, { "ordinal": 10, + "name": "weekly_streak_amount", + "type_info": "Int4" + }, + { + "ordinal": 11, "name": "weekly_streak_latest_time_string", "type_info": "Text" }, { - "ordinal": 11, + "ordinal": 12, "name": "monthly_streak_best", "type_info": "Int4" }, { - "ordinal": 12, + "ordinal": 13, "name": "monthly_streak_amount", "type_info": "Int4" }, { - "ordinal": 13, + "ordinal": 14, "name": "monthly_streak_latest_time_string", "type_info": "Text" }, { - "ordinal": 14, + "ordinal": 15, "name": "total_rating", "type_info": "Int4" }, { - "ordinal": 15, + "ordinal": 16, "name": "place", "type_info": "Int8" }, { - "ordinal": 16, + "ordinal": 17, "name": "permanent_bonus", "type_info": "Int4" } @@ -112,9 +117,10 @@ false, false, false, + false, null, false ] }, - "hash": "4311e3c06d78c4e89d02f37dc509c022d556434529f8f340ac230a9c5e8e354c" + "hash": "5c9c5c0c4116a9b18fb2b981cda5a55b929a4219f9ec80f4f5c231f2e7a55596" } diff --git a/server/sql/get_leaderboard.sql b/server/sql/get_leaderboard.sql index 7e70c1b..b461a38 100644 --- a/server/sql/get_leaderboard.sql +++ b/server/sql/get_leaderboard.sql @@ -7,6 +7,7 @@ SELECT largest_score, prs_opened, prs_merged, + prs_scored, weekly_streak.best as weekly_streak_best, weekly_streak.amount as weekly_streak_amount, weekly_streak.latest_time_string as weekly_streak_latest_time_string, diff --git a/server/src/db/types.rs b/server/src/db/types.rs index cea892b..332a6c7 100644 --- a/server/src/db/types.rs +++ b/server/src/db/types.rs @@ -11,6 +11,7 @@ pub struct LeaderboardRecord { pub largest_score: i32, pub prs_opened: i32, pub prs_merged: i32, + pub prs_scored: i32, pub weekly_streak_best: i32, pub monthly_streak_best: i32, pub weekly_streak_latest_time_string: String, diff --git a/server/src/types.rs b/server/src/types.rs index 9b5a2cf..e002b61 100644 --- a/server/src/types.rs +++ b/server/src/types.rs @@ -91,6 +91,7 @@ pub struct LeaderboardResponse { pub merged_prs: u32, pub score: u32, pub place: u32, + pub scored_prs: u32, } impl From for LeaderboardResponse { @@ -132,6 +133,7 @@ impl From for LeaderboardResponse { score: record.total_score as u32, place: record.place as u32, rank, + scored_prs: record.prs_scored as u32, } } }