pedantic clippy
This commit is contained in:
@@ -396,9 +396,9 @@ AND r.left_at IS NOT NULL;",
|
|||||||
let teams = self.teams(&mut *db).await;
|
let teams = self.teams(&mut *db).await;
|
||||||
|
|
||||||
let mut missing_teams = Vec::new();
|
let mut missing_teams = Vec::new();
|
||||||
for team in teams.into_iter() {
|
for team in teams {
|
||||||
if !team.been_at_station(&mut *db, self).await {
|
if !team.been_at_station(&mut *db, self).await {
|
||||||
missing_teams.push(team)
|
missing_teams.push(team);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -2,7 +2,6 @@ use crate::Station;
|
|||||||
use serde::Serialize;
|
use serde::Serialize;
|
||||||
use sqlx::Acquire;
|
use sqlx::Acquire;
|
||||||
use sqlx::SqliteConnection;
|
use sqlx::SqliteConnection;
|
||||||
use std::ops::DerefMut;
|
|
||||||
use thiserror::Error;
|
use thiserror::Error;
|
||||||
|
|
||||||
#[derive(Error, Debug, PartialEq, Serialize)]
|
#[derive(Error, Debug, PartialEq, Serialize)]
|
||||||
@@ -38,7 +37,7 @@ impl Station {
|
|||||||
amount_people,
|
amount_people,
|
||||||
self.id
|
self.id
|
||||||
)
|
)
|
||||||
.execute(transaction.deref_mut())
|
.execute(&mut *transaction)
|
||||||
.await
|
.await
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
@@ -107,9 +106,7 @@ mod test {
|
|||||||
let mut db = &mut *pool.acquire().await.unwrap();
|
let mut db = &mut *pool.acquire().await.unwrap();
|
||||||
|
|
||||||
let station = Station::create(db, "Teststation").await.unwrap();
|
let station = Station::create(db, "Teststation").await.unwrap();
|
||||||
let crew_station = Station::create(db, "Bemannte Teststation")
|
let crew_station = Station::create(db, "Bemannte Teststation").await.unwrap();
|
||||||
.await
|
|
||||||
.unwrap();
|
|
||||||
let route = Route::create(db, "Testroute").await.unwrap();
|
let route = Route::create(db, "Testroute").await.unwrap();
|
||||||
route.add_station(db, &station).await.unwrap();
|
route.add_station(db, &station).await.unwrap();
|
||||||
route.add_station(db, &crew_station).await.unwrap();
|
route.add_station(db, &crew_station).await.unwrap();
|
||||||
|
@@ -73,9 +73,9 @@ pub(crate) async fn station_pdf(stations: Vec<Station>) -> Vec<u8> {
|
|||||||
|
|
||||||
write!(
|
write!(
|
||||||
content,
|
content,
|
||||||
r#")
|
r")
|
||||||
|
|
||||||
#create_card_grid(cards)"#
|
#create_card_grid(cards)"
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
@@ -54,15 +54,14 @@ impl TypstWrapperWorld {
|
|||||||
source: Source::detached(source),
|
source: Source::detached(source),
|
||||||
time: time::OffsetDateTime::now_utc(),
|
time: time::OffsetDateTime::now_utc(),
|
||||||
cache_directory: std::env::var_os("CACHE_DIRECTORY")
|
cache_directory: std::env::var_os("CACHE_DIRECTORY")
|
||||||
.map(|os_path| os_path.into())
|
.map_or(std::env::temp_dir(), std::convert::Into::into),
|
||||||
.unwrap_or(std::env::temp_dir()),
|
|
||||||
http: ureq::Agent::new_with_defaults(),
|
http: ureq::Agent::new_with_defaults(),
|
||||||
files: Arc::new(Mutex::new(HashMap::new())),
|
files: Arc::new(Mutex::new(HashMap::new())),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// A File that will be stored in the HashMap.
|
/// A File that will be stored in the `HashMap`.
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
struct FileEntry {
|
struct FileEntry {
|
||||||
bytes: Bytes,
|
bytes: Bytes,
|
||||||
|
@@ -15,6 +15,7 @@ use axum::{
|
|||||||
use maud::{html, Markup};
|
use maud::{html, Markup};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::SqlitePool;
|
use sqlx::SqlitePool;
|
||||||
|
use std::fmt::Write;
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
use tower_sessions::Session;
|
use tower_sessions::Session;
|
||||||
|
|
||||||
@@ -412,16 +413,13 @@ async fn update_amount_people(
|
|||||||
return Redirect::to("/admin/station");
|
return Redirect::to("/admin/station");
|
||||||
};
|
};
|
||||||
|
|
||||||
match station
|
match station.update_amount_people(db, form.amount_people).await {
|
||||||
.update_amount_people(db, form.amount_people)
|
|
||||||
.await
|
|
||||||
{
|
|
||||||
Ok(()) => suc!(
|
Ok(()) => suc!(
|
||||||
session,
|
session,
|
||||||
t!("station_new_crew_amount", station = station.name)
|
t!("station_new_crew_amount", station = station.name)
|
||||||
),
|
),
|
||||||
Err(UpdateAmountPeopleError::LastStationCantBeCrewlessIfTeamExists) => {
|
Err(UpdateAmountPeopleError::LastStationCantBeCrewlessIfTeamExists) => {
|
||||||
er!(session, t!("last_station_has_to_be_crewful"))
|
er!(session, t!("last_station_has_to_be_crewful"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -537,22 +535,24 @@ async fn quick_post(
|
|||||||
|
|
||||||
for (team_id, points) in &form.fields {
|
for (team_id, points) in &form.fields {
|
||||||
let Ok(team_id) = team_id.parse::<i64>() else {
|
let Ok(team_id) = team_id.parse::<i64>() else {
|
||||||
ret.push_str(&format!(
|
let _ = write!(
|
||||||
|
ret,
|
||||||
"Skipped team_id={team_id} because this id can't be parsed as i64"
|
"Skipped team_id={team_id} because this id can't be parsed as i64"
|
||||||
));
|
);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let Ok(points) = points.parse::<i64>() else {
|
let Ok(points) = points.parse::<i64>() else {
|
||||||
ret.push_str(&format!(
|
let _ = write!(
|
||||||
"Skipped team_id={team_id} because points {} can't be parsed as i64",
|
ret,
|
||||||
points
|
"Skipped team_id={team_id} because {points} points can't be parsed as i64",
|
||||||
));
|
);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let Some(team) = Team::find_by_id(db, team_id).await else {
|
let Some(team) = Team::find_by_id(db, team_id).await else {
|
||||||
ret.push_str(&format!(
|
let _ = write!(
|
||||||
|
ret,
|
||||||
"Skipped team_id={team_id} because this team does not exist"
|
"Skipped team_id={team_id} because this team does not exist"
|
||||||
));
|
);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
if Rating::find_by_team_and_station(db, &team, &station)
|
if Rating::find_by_team_and_station(db, &team, &station)
|
||||||
|
@@ -15,6 +15,7 @@ use axum::{
|
|||||||
use maud::{html, Markup, PreEscaped};
|
use maud::{html, Markup, PreEscaped};
|
||||||
use serde::Deserialize;
|
use serde::Deserialize;
|
||||||
use sqlx::{SqliteConnection, SqlitePool};
|
use sqlx::{SqliteConnection, SqlitePool};
|
||||||
|
use std::fmt::Write;
|
||||||
use std::{collections::HashMap, sync::Arc};
|
use std::{collections::HashMap, sync::Arc};
|
||||||
use tower_sessions::Session;
|
use tower_sessions::Session;
|
||||||
|
|
||||||
@@ -208,21 +209,24 @@ async fn quick_post(
|
|||||||
|
|
||||||
for (station_id, points) in &form.fields {
|
for (station_id, points) in &form.fields {
|
||||||
let Ok(station_id) = station_id.parse::<i64>() else {
|
let Ok(station_id) = station_id.parse::<i64>() else {
|
||||||
ret.push_str(&format!(
|
let _ = write!(
|
||||||
|
ret,
|
||||||
"Skipped stationid={station_id} because this id can't be parsed as i64"
|
"Skipped stationid={station_id} because this id can't be parsed as i64"
|
||||||
));
|
);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let Ok(points) = points.parse::<i64>() else {
|
let Ok(points) = points.parse::<i64>() else {
|
||||||
ret.push_str(&format!(
|
let _ = write!(
|
||||||
"Skipped stationid={station_id} because points {points} can't be parsed as i64",
|
ret,
|
||||||
));
|
"Skipped stationid={station_id} because {points} points can't be parsed as i64",
|
||||||
|
);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
let Some(station) = Station::find_by_id(&mut *db, station_id).await else {
|
let Some(station) = Station::find_by_id(&mut *db, station_id).await else {
|
||||||
ret.push_str(&format!(
|
let _ = write!(
|
||||||
|
ret,
|
||||||
"Skipped stationid={station_id} because this station does not exist"
|
"Skipped stationid={station_id} because this station does not exist"
|
||||||
));
|
);
|
||||||
continue;
|
continue;
|
||||||
};
|
};
|
||||||
if Rating::find_by_team_and_station(db, &team, &station)
|
if Rating::find_by_team_and_station(db, &team, &station)
|
||||||
|
@@ -173,27 +173,24 @@ impl TeamsAtStationLocation {
|
|||||||
let mut done = true;
|
let mut done = true;
|
||||||
|
|
||||||
for team in teams {
|
for team in teams {
|
||||||
match Rating::find_by_team_and_station(db, &team, station).await {
|
if let Some(rating) = Rating::find_by_team_and_station(db, &team, station).await {
|
||||||
Some(rating) => {
|
if rating.left_at.is_some() {
|
||||||
if rating.left_at.is_some() {
|
if rating.points.is_some() {
|
||||||
if rating.points.is_some() {
|
left_and_rated.push((team, rating));
|
||||||
left_and_rated.push((team, rating));
|
|
||||||
} else {
|
|
||||||
done = false;
|
|
||||||
left_not_yet_rated.push((team, rating));
|
|
||||||
}
|
|
||||||
} else if rating.started_at.is_some() {
|
|
||||||
done = false;
|
|
||||||
doing.push((team, rating));
|
|
||||||
} else {
|
} else {
|
||||||
done = false;
|
done = false;
|
||||||
waiting.push((team, rating));
|
left_not_yet_rated.push((team, rating));
|
||||||
}
|
}
|
||||||
}
|
} else if rating.started_at.is_some() {
|
||||||
None => {
|
|
||||||
done = false;
|
done = false;
|
||||||
not_yet_here.push(team)
|
doing.push((team, rating));
|
||||||
|
} else {
|
||||||
|
done = false;
|
||||||
|
waiting.push((team, rating));
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
done = false;
|
||||||
|
not_yet_here.push(team);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -211,9 +208,9 @@ impl TeamsAtStationLocation {
|
|||||||
not_yet_here_by_route,
|
not_yet_here_by_route,
|
||||||
waiting,
|
waiting,
|
||||||
doing,
|
doing,
|
||||||
done,
|
|
||||||
left_not_yet_rated,
|
left_not_yet_rated,
|
||||||
left_and_rated,
|
left_and_rated,
|
||||||
|
done,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user