Skip to content

Commit

Permalink
fix: invalid timestamp edge case
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushtom committed Nov 8, 2023
1 parent e7909a7 commit 6dea7cf
Showing 1 changed file with 19 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/endpoints/leaderboard/get_ranking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,25 @@ pub async fn get_user_rank(collection: &Collection<Document>, address: &String,
Ok(mut cursor) => {
let mut data = Document::new();
while let Some(result) = cursor.try_next().await.unwrap() {
data.insert("user_rank", result.get("rank").unwrap());
data.insert("total_users", result.get("total_users").unwrap());
match result.get("rank") {
Some(rank) => {
data.insert("user_rank", rank);
}
None => {
data.insert("user_rank", 1);
return data;
}
}

match result.get("total_users") {
Some(total_users) => {
data.insert("total_users", total_users);
}
None => {
data.insert("total_users", 0);
return data;
}
}
}
data
}
Expand Down

0 comments on commit 6dea7cf

Please sign in to comment.