Skip to content

Commit

Permalink
chore: remove warning
Browse files Browse the repository at this point in the history
  • Loading branch information
ayushtom committed Jan 4, 2024
1 parent fbd6ff8 commit 577ab88
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
28 changes: 16 additions & 12 deletions src/endpoints/leaderboard/get_ranking.rs
Original file line number Diff line number Diff line change
Expand Up @@ -238,19 +238,23 @@ pub async fn handler(
State(state): State<Arc<AppState>>,
Query(query): Query<GetCompletedQuestsQuery>,
) -> impl IntoResponse {
let mut time_gap = 0;

// check value of duration and set time_gap accordingly
if query.duration == "week" {
time_gap = get_timestamp_from_days(7);
} else if query.duration == "month" {
time_gap = get_timestamp_from_days(30);
} else if query.duration == "all" {
time_gap = 0;
} else {
return get_error("Invalid duration".to_string());
}


// check value of duration and set time_gap accordingly using match and respective timestamp
let time_gap = match query.duration.as_str() {
"week" => {
get_timestamp_from_days(7)
}
"month" => {
get_timestamp_from_days(30)
}
"all" => {
0
}
_ => {
return get_error("Invalid duration".to_string());
}
};
// get collection
let users_collection = state.db.collection::<Document>("leaderboard_table");

Expand Down
26 changes: 15 additions & 11 deletions src/endpoints/leaderboard/get_static_info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,18 +39,22 @@ pub async fn handler(
) -> impl IntoResponse {
let addr: String = query.addr.to_string();
let collection = state.db.collection::<Document>("leaderboard_table");
let mut time_gap = 0;

// check value of duration and set time_gap accordingly
if query.duration == "week" {
time_gap = get_timestamp_from_days(7);
} else if query.duration == "month" {
time_gap = get_timestamp_from_days(30);
} else if query.duration == "all" {
time_gap = 0;
} else {
return get_error("Invalid duration".to_string());
}
// check value of duration and set time_gap accordingly using match and respective timestamp
let time_gap = match query.duration.as_str() {
"week" => {
get_timestamp_from_days(7)
}
"month" => {
get_timestamp_from_days(30)
}
"all" => {
0
}
_ => {
return get_error("Invalid duration".to_string());
}
};

let leaderboard_pipeline = vec![
doc! {
Expand Down

0 comments on commit 577ab88

Please sign in to comment.