pedantic clippy

This commit is contained in:
2025-05-15 19:40:16 +02:00
parent 69aed3be27
commit 2a0098b0cb
7 changed files with 46 additions and 49 deletions

View File

@@ -396,9 +396,9 @@ AND r.left_at IS NOT NULL;",
let teams = self.teams(&mut *db).await;
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 {
missing_teams.push(team)
missing_teams.push(team);
}
}

View File

@@ -2,7 +2,6 @@ use crate::Station;
use serde::Serialize;
use sqlx::Acquire;
use sqlx::SqliteConnection;
use std::ops::DerefMut;
use thiserror::Error;
#[derive(Error, Debug, PartialEq, Serialize)]
@@ -38,7 +37,7 @@ impl Station {
amount_people,
self.id
)
.execute(transaction.deref_mut())
.execute(&mut *transaction)
.await
.unwrap();
@@ -107,9 +106,7 @@ mod test {
let mut db = &mut *pool.acquire().await.unwrap();
let station = Station::create(db, "Teststation").await.unwrap();
let crew_station = Station::create(db, "Bemannte Teststation")
.await
.unwrap();
let crew_station = Station::create(db, "Bemannte Teststation").await.unwrap();
let route = Route::create(db, "Testroute").await.unwrap();
route.add_station(db, &station).await.unwrap();
route.add_station(db, &crew_station).await.unwrap();

View File

@@ -73,9 +73,9 @@ pub(crate) async fn station_pdf(stations: Vec<Station>) -> Vec<u8> {
write!(
content,
r#")
r")
#create_card_grid(cards)"#
#create_card_grid(cards)"
)
.unwrap();

View File

@@ -54,15 +54,14 @@ impl TypstWrapperWorld {
source: Source::detached(source),
time: time::OffsetDateTime::now_utc(),
cache_directory: std::env::var_os("CACHE_DIRECTORY")
.map(|os_path| os_path.into())
.unwrap_or(std::env::temp_dir()),
.map_or(std::env::temp_dir(), std::convert::Into::into),
http: ureq::Agent::new_with_defaults(),
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)]
struct FileEntry {
bytes: Bytes,

View File

@@ -15,6 +15,7 @@ use axum::{
use maud::{html, Markup};
use serde::Deserialize;
use sqlx::SqlitePool;
use std::fmt::Write;
use std::{collections::HashMap, sync::Arc};
use tower_sessions::Session;
@@ -412,16 +413,13 @@ async fn update_amount_people(
return Redirect::to("/admin/station");
};
match station
.update_amount_people(db, form.amount_people)
.await
{
match station.update_amount_people(db, form.amount_people).await {
Ok(()) => suc!(
session,
t!("station_new_crew_amount", station = station.name)
),
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 {
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"
));
);
continue;
};
let Ok(points) = points.parse::<i64>() else {
ret.push_str(&format!(
"Skipped team_id={team_id} because points {} can't be parsed as i64",
points
));
let _ = write!(
ret,
"Skipped team_id={team_id} because {points} points can't be parsed as i64",
);
continue;
};
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"
));
);
continue;
};
if Rating::find_by_team_and_station(db, &team, &station)

View File

@@ -15,6 +15,7 @@ use axum::{
use maud::{html, Markup, PreEscaped};
use serde::Deserialize;
use sqlx::{SqliteConnection, SqlitePool};
use std::fmt::Write;
use std::{collections::HashMap, sync::Arc};
use tower_sessions::Session;
@@ -208,21 +209,24 @@ async fn quick_post(
for (station_id, points) in &form.fields {
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"
));
);
continue;
};
let Ok(points) = points.parse::<i64>() else {
ret.push_str(&format!(
"Skipped stationid={station_id} because points {points} can't be parsed as i64",
));
let _ = write!(
ret,
"Skipped stationid={station_id} because {points} points can't be parsed as i64",
);
continue;
};
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"
));
);
continue;
};
if Rating::find_by_team_and_station(db, &team, &station)

View File

@@ -173,27 +173,24 @@ impl TeamsAtStationLocation {
let mut done = true;
for team in teams {
match Rating::find_by_team_and_station(db, &team, station).await {
Some(rating) => {
if rating.left_at.is_some() {
if rating.points.is_some() {
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));
if let Some(rating) = Rating::find_by_team_and_station(db, &team, station).await {
if rating.left_at.is_some() {
if rating.points.is_some() {
left_and_rated.push((team, rating));
} else {
done = false;
waiting.push((team, rating));
left_not_yet_rated.push((team, rating));
}
}
None => {
} else if rating.started_at.is_some() {
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,
waiting,
doing,
done,
left_not_yet_rated,
left_and_rated,
done,
}
}
}