diff --git a/src/model/boat.rs b/src/model/boat.rs index a851180..e25af7a 100644 --- a/src/model/boat.rs +++ b/src/model/boat.rs @@ -171,6 +171,16 @@ AND date('now') BETWEEN start_date AND end_date;", .is_some() } + pub(crate) fn cat(&self) -> String { + if self.external { + "Vereinsfremde Boote".to_string() + } else if self.default_shipmaster_only_steering { + format!("{}+", self.amount_seats - 1) + } else { + format!("{}x", self.amount_seats) + } + } + async fn boats_to_details(db: &SqlitePool, boats: Vec) -> Vec { let mut res = Vec::new(); for boat in boats { @@ -181,13 +191,7 @@ AND date('now') BETWEEN start_date AND end_date;", if boat.is_locked(db).await { damage = BoatDamage::Locked; } - let cat = if boat.external { - "Vereinsfremde Boote".to_string() - } else if boat.default_shipmaster_only_steering { - format!("{}+", boat.amount_seats - 1) - } else { - format!("{}x", boat.amount_seats) - }; + let cat = boat.cat(); res.push(BoatWithDetails { damage, diff --git a/src/model/stat.rs b/src/model/stat.rs index e79bbd9..dad5ca0 100644 --- a/src/model/stat.rs +++ b/src/model/stat.rs @@ -16,6 +16,7 @@ pub struct BoatStat { #[derive(Serialize, Clone)] pub struct SingleBoatStat { name: String, + cat: String, location: String, owner: String, years: HashMap, @@ -71,6 +72,7 @@ ORDER BY } let year: String = format!("{year}"); + let cat = boat.cat(); let rowed_km: i32 = row.get("rowed_km"); @@ -80,6 +82,7 @@ ORDER BY name, location, owner, + cat, years: HashMap::new(), }); boat_stat.years.insert(year, rowed_km); diff --git a/templates/index.html.tera b/templates/index.html.tera index ab3047e..890ff4f 100644 --- a/templates/index.html.tera +++ b/templates/index.html.tera @@ -103,7 +103,7 @@