Skip to content

Commit 10d63da

Browse files
committed
chore: fmt
1 parent 48e7de2 commit 10d63da

File tree

7 files changed

+60
-28
lines changed

7 files changed

+60
-28
lines changed

crates/api/src/api/challenges.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,15 @@ pub async fn submit(
200200
.await?
201201
.public_id
202202
);
203-
client.post(u).json(&WebhookData {
204-
content: msg,
205-
embeds: None,
206-
attachments: Vec::new(),
207-
}).send().await?;
203+
client
204+
.post(u)
205+
.json(&WebhookData {
206+
content: msg,
207+
embeds: None,
208+
attachments: Vec::new(),
209+
})
210+
.send()
211+
.await?;
208212
}
209213
}
210214
}

crates/api/src/api/leaderboard.rs

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
use crate::{extractors::Auth, Error, Result, State, DB};
2-
use axum::{extract::{State as StateE, Path}, routing::get, Json, Router};
2+
use axum::{
3+
extract::{Path, State as StateE},
4+
routing::get,
5+
Json, Router,
6+
};
37
use chrono::{NaiveDateTime, Utc};
48
use serde::Serialize;
59

@@ -93,7 +97,11 @@ async fn calculate_score_history(
9397
Ok(history)
9498
}
9599

96-
async fn leaderboard(db: &DB, event_start_time: NaiveDateTime, division: Option<String>) -> Result<Vec<LeaderboardEntry>> {
100+
async fn leaderboard(
101+
db: &DB,
102+
event_start_time: NaiveDateTime,
103+
division: Option<String>,
104+
) -> Result<Vec<LeaderboardEntry>> {
97105
let db_entries = sqlx::query_as!(
98106
DbLeaderboardEntry,
99107
r#"
@@ -163,19 +171,25 @@ async fn leaderboard(db: &DB, event_start_time: NaiveDateTime, division: Option<
163171
Ok(leaderboard_entries)
164172
}
165173

166-
async fn get_lb(StateE(state): StateE<State>,
174+
async fn get_lb(
175+
StateE(state): StateE<State>,
167176
division: Option<Path<String>>,
168177
) -> Result<Json<Vec<LeaderboardEntry>>> {
169178
if Utc::now().naive_utc() < state.event.start_time {
170179
return Err(Error::EventNotStarted(state.event.start_time.clone()));
171180
}
172181

173182
let division = division.map(|x| x.0);
174-
if division != None && state.event.divisions.get(division.as_ref().unwrap()).is_none() {
183+
if division != None
184+
&& state
185+
.event
186+
.divisions
187+
.get(division.as_ref().unwrap())
188+
.is_none()
189+
{
175190
return Err(Error::NotFoundDivision);
176191
}
177-
178-
192+
179193
return leaderboard(&state.db, state.event.start_time, division)
180194
.await
181195
.map(Json);
@@ -184,5 +198,5 @@ async fn get_lb(StateE(state): StateE<State>,
184198
pub fn router() -> Router<crate::State> {
185199
Router::new()
186200
.route("/", get(get_lb))
187-
.route("/{division}", get(get_lb))
201+
.route("/{division}", get(get_lb))
188202
}

crates/api/src/api/profile.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::{extractors::Auth, jwt::Claims, Result, State, DB, Error};
1+
use crate::{extractors::Auth, jwt::Claims, Error, Result, State, DB};
22
use axum::{
33
extract::{Path, State as StateE},
44
routing::{get, post},
@@ -10,7 +10,6 @@ use validator::Validate;
1010

1111
use super::auth::{Team, TeamInfo, VerificationRequest};
1212

13-
1413
async fn update(
1514
StateE(state): StateE<State>,
1615
Auth(Claims { team_id, .. }): Auth,
@@ -38,7 +37,13 @@ async fn update(
3837
}
3938

4039
if current_team.division != payload.division {
41-
if payload.division != None && state.event.divisions.get(payload.division.as_ref().unwrap()).is_none() {
40+
if payload.division != None
41+
&& state
42+
.event
43+
.divisions
44+
.get(payload.division.as_ref().unwrap())
45+
.is_none()
46+
{
4247
return Err(Error::NotFoundDivision);
4348
}
4449
sqlx::query!(
@@ -49,7 +54,6 @@ async fn update(
4954
)
5055
.execute(&state.db)
5156
.await?;
52-
5357
}
5458

5559
if current_team.email != payload.email {

crates/api/src/error.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ impl IntoResponse for Error {
6363
Error::Validation(_) => (StatusCode::BAD_REQUEST, "validation_error"),
6464
Error::Deploy(_) => (StatusCode::BAD_REQUEST, "deploy_error"),
6565
Error::InvalidToken => (StatusCode::UNAUTHORIZED, "invalid_token"),
66-
Error::NotFoundChallenge | Error::NotFoundTeam | Error::NotFoundDivision => (StatusCode::NOT_FOUND, "not_found"),
66+
Error::NotFoundChallenge | Error::NotFoundTeam | Error::NotFoundDivision => {
67+
(StatusCode::NOT_FOUND, "not_found")
68+
}
6769
Error::EventNotStarted(start_time) => {
6870
// Event not started special cased to return start time
6971
return (

crates/api/src/event.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
use axum::{extract::State as StateE, routing::get, Json, Router};
22
use chrono::NaiveDateTime;
33
use serde::{Deserialize, Serialize};
4-
use std::{fs, collections::HashMap};
4+
use std::{collections::HashMap, fs};
55

66
use crate::{Result, State};
77

crates/api/src/extractors.rs

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@ use crate::{
44
config::Config,
55
jwt::{decode_jwt, Claims},
66
};
7-
use axum::{extract::{FromRequestParts, OptionalFromRequestParts}, http::request::Parts, RequestPartsExt};
7+
use axum::{
8+
extract::{FromRequestParts, OptionalFromRequestParts},
9+
http::request::Parts,
10+
RequestPartsExt,
11+
};
812
use axum_extra::extract::CookieJar;
913

1014
#[derive(Debug, Clone)]
@@ -34,7 +38,10 @@ where
3438
{
3539
type Rejection = crate::Error;
3640

37-
async fn from_request_parts(parts: &mut Parts, cfg: &B) -> Result<Option<Self>, Self::Rejection> {
41+
async fn from_request_parts(
42+
parts: &mut Parts,
43+
cfg: &B,
44+
) -> Result<Option<Self>, Self::Rejection> {
3845
match <Auth as FromRequestParts<B>>::from_request_parts(parts, cfg).await {
3946
Ok(a) => Ok(Some(a)),
4047
Err(e) => match e {

crates/deployer-server/src/main.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,8 @@ mod error;
1010

1111
use config::State;
1212
use error::Result;
13-
use tokio_util::{sync::CancellationToken, task::TaskTracker};
1413
use log::error;
15-
14+
use tokio_util::{sync::CancellationToken, task::TaskTracker};
1615

1716
#[tokio::main]
1817
async fn main() -> eyre::Result<()> {
@@ -39,13 +38,12 @@ async fn main() -> eyre::Result<()> {
3938
})?;
4039

4140
let state = State::new(config::StateInner {
42-
config: cfg,
43-
db: pool.clone(),
44-
challenge_data: challs.into(),
45-
tasks: tt.clone(),
41+
config: cfg,
42+
db: pool.clone(),
43+
challenge_data: challs.into(),
44+
tasks: tt.clone(),
4645
});
4746

48-
4947
let inherited_containers = sqlx::query_as!(
5048
api::ChallengeDeploymentRow,
5149
"SELECT * FROM challenge_deployments WHERE destroyed_at IS NULL AND expired_at IS NOT NULL"
@@ -67,7 +65,10 @@ async fn main() -> eyre::Result<()> {
6765
deploy::destroy_challenge_task(state_clone, container).await;
6866
});
6967
} else {
70-
error!("failed to start cleanup task for deployment {}", container_id);
68+
error!(
69+
"failed to start cleanup task for deployment {}",
70+
container_id
71+
);
7172
}
7273
}
7374

0 commit comments

Comments
 (0)