From 670f418625db31ba7abd22b43a40bad23c6e7631 Mon Sep 17 00:00:00 2001 From: Pavel Perestoronin Date: Mon, 20 Feb 2023 15:46:53 +0100 Subject: [PATCH] =?UTF-8?q?=E2=AC=86=EF=B8=8F=20Chores?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Cargo.lock | 16 ++-- src/database/mongodb/models/account.rs | 2 +- src/database/mongodb/models/tank_snapshot.rs | 2 +- src/tankopedia.rs | 16 ---- src/tankopedia/generated.rs | 74 ++++++++++++++-- src/tankopedia/tankopedia.json | 90 ++++++++++++++++++-- src/wargaming.rs | 10 +-- src/wargaming/models/tank_id.rs | 2 +- src/wargaming/models/vehicle.rs | 2 +- src/web/partials.rs | 4 +- src/web/tracking_code.rs | 3 +- src/web/views/player.rs | 18 +++- src/web/views/player/display_preferences.rs | 2 +- 13 files changed, 189 insertions(+), 52 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 85d8e6ed..f267536f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2318,9 +2318,9 @@ checksum = "6ac9a59f73473f1b8d852421e59e64809f025994837ef743615c6d0c5b305160" [[package]] name = "poem" -version = "1.3.54" +version = "1.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8944cb225d49272f3a3fab509cea681e5b5f825f79eda78cb48cf8fb36fa2fa9" +checksum = "c0608069d4999c3c02d49dff261663f2e73a8f7b00b7cd364fb5e93e419dafa1" dependencies = [ "anyhow", "async-trait", @@ -2358,9 +2358,9 @@ dependencies = [ [[package]] name = "poem-derive" -version = "1.3.54" +version = "1.3.55" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "37f47418a66a9280874efc8d503c1d7e5b22b5c4b77c661d9ade0ee73a87b17a" +checksum = "3b839bad877aa933dd00901abd127a44496130e3def48e079d60e43f2c8a33cc" dependencies = [ "proc-macro-crate", "proc-macro2", @@ -3127,9 +3127,9 @@ checksum = "7bd3e3206899af3f8b12af284fafc038cc1dc2b41d1b89dd17297221c5d225de" [[package]] name = "slab" -version = "0.4.7" +version = "0.4.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4614a76b2a8be0058caa9dbbaf66d988527d86d003c11a94fbd335d7661edcef" +checksum = "6528351c9bc8ab22353f9d776db39a20288e8d6c37ef8cfe3317cf875eecfc2d" dependencies = [ "autocfg", ] @@ -3526,9 +3526,9 @@ dependencies = [ [[package]] name = "tokio-stream" -version = "0.1.11" +version = "0.1.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d660770404473ccd7bc9f8b28494a811bc18542b915c0855c51e8f419d5223ce" +checksum = "8fb52b74f05dbf495a8fba459fdc331812b96aa086d9eb78101fa0d4569c3313" dependencies = [ "futures-core", "pin-project-lite", diff --git a/src/database/mongodb/models/account.rs b/src/database/mongodb/models/account.rs index 82abe9fc..58936a70 100644 --- a/src/database/mongodb/models/account.rs +++ b/src/database/mongodb/models/account.rs @@ -121,7 +121,7 @@ impl Account { Self::collection(in_) .update_one(filter, update, options) .await - .with_context(|| format!("failed to ensure the account #{} existence", account_id))?; + .with_context(|| format!("failed to ensure the account #{account_id} existence"))?; Ok(()) } diff --git a/src/database/mongodb/models/tank_snapshot.rs b/src/database/mongodb/models/tank_snapshot.rs index 1d8b07e8..b3f0780f 100644 --- a/src/database/mongodb/models/tank_snapshot.rs +++ b/src/database/mongodb/models/tank_snapshot.rs @@ -212,7 +212,7 @@ impl TankSnapshot { .await .context("timed out to retrieve the latest tanks snapshots")?? .with_context(|| { - format!("failed to retrieve the latest tank snapshots for #{}", account_id) + format!("failed to retrieve the latest tank snapshots for #{account_id}") })?; let stream = cursor .try_filter_map(|document| async move { diff --git a/src/tankopedia.rs b/src/tankopedia.rs index e8e6045f..11da3dec 100644 --- a/src/tankopedia.rs +++ b/src/tankopedia.rs @@ -118,14 +118,6 @@ fn insert_missing_vehicles(vehicles: &mut BTreeMap) -> Result { nation: Nation::Japan, type_: TankType::Light, }, - Vehicle { - tank_id: 3329, - name: Cow::Borrowed("MS-1 mod. 1"), - tier: 1, - is_premium: false, - nation: Nation::Ussr, - type_: TankType::Light, - }, Vehicle { tank_id: 23297, name: Cow::Borrowed("Объект 244"), @@ -190,14 +182,6 @@ fn insert_missing_vehicles(vehicles: &mut BTreeMap) -> Result { nation: Nation::Europe, type_: TankType::Heavy, }, - Vehicle { - tank_id: 26913, - name: Cow::Borrowed("Frosty"), - tier: 6, - is_premium: true, - nation: Nation::Usa, - type_: TankType::Light, - }, Vehicle { tank_id: 10545, name: Cow::Borrowed("Wind"), diff --git a/src/tankopedia/generated.rs b/src/tankopedia/generated.rs index 07b8dc97..2b2f19c7 100644 --- a/src/tankopedia/generated.rs +++ b/src/tankopedia/generated.rs @@ -101,6 +101,14 @@ pub static GENERATED: phf::Map = phf::phf_map! { nation: Nation::Other, type_: TankType::Heavy, }, + 10369_u32 => Vehicle { + tank_id: 10369, + name: Cow::Borrowed("Controcarro 3 Minotauro"), + tier: 10, + is_premium: false, + nation: Nation::Europe, + type_: TankType::AT, + }, 1041_u32 => Vehicle { tank_id: 1041, name: Cow::Borrowed("StuG III Ausf. G"), @@ -149,6 +157,14 @@ pub static GENERATED: phf::Map = phf::phf_map! { nation: Nation::Usa, type_: TankType::Medium, }, + 10625_u32 => Vehicle { + tank_id: 10625, + name: Cow::Borrowed("Controcarro 1 Mk. 2"), + tier: 9, + is_premium: false, + nation: Nation::Europe, + type_: TankType::AT, + }, 1073_u32 => Vehicle { tank_id: 1073, name: Cow::Borrowed("T-34-1"), @@ -189,6 +205,14 @@ pub static GENERATED: phf::Map = phf::phf_map! { nation: Nation::France, type_: TankType::AT, }, + 10881_u32 => Vehicle { + tank_id: 10881, + name: Cow::Borrowed("Semovente Controcarro mod. 1964"), + tier: 8, + is_premium: false, + nation: Nation::Europe, + type_: TankType::AT, + }, 1089_u32 => Vehicle { tank_id: 1089, name: Cow::Borrowed("B1"), @@ -237,6 +261,14 @@ pub static GENERATED: phf::Map = phf::phf_map! { nation: Nation::France, type_: TankType::AT, }, + 11137_u32 => Vehicle { + tank_id: 11137, + name: Cow::Borrowed("Semovente Controcarro mod. 1956"), + tier: 7, + is_premium: false, + nation: Nation::Europe, + type_: TankType::AT, + }, 1121_u32 => Vehicle { tank_id: 1121, name: Cow::Borrowed("Type 5 Chi-Ri"), @@ -285,6 +317,14 @@ pub static GENERATED: phf::Map = phf::phf_map! { nation: Nation::Other, type_: TankType::Heavy, }, + 11393_u32 => Vehicle { + tank_id: 11393, + name: Cow::Borrowed("Semovente M43 Bassotto"), + tier: 6, + is_premium: false, + nation: Nation::Europe, + type_: TankType::AT, + }, 11521_u32 => Vehicle { tank_id: 11521, name: Cow::Borrowed("IS-8"), @@ -325,6 +365,14 @@ pub static GENERATED: phf::Map = phf::phf_map! { nation: Nation::France, type_: TankType::AT, }, + 11649_u32 => Vehicle { + tank_id: 11649, + name: Cow::Borrowed("Semovente M41"), + tier: 5, + is_premium: false, + nation: Nation::Europe, + type_: TankType::AT, + }, 11777_u32 => Vehicle { tank_id: 11777, name: Cow::Borrowed("KV-1"), @@ -1007,7 +1055,7 @@ pub static GENERATED: phf::Map = phf::phf_map! { }, 18449_u32 => Vehicle { tank_id: 18449, - name: Cow::Borrowed("Spähpanzer Ru 251"), + name: Cow::Borrowed("Ru 251"), tier: 8, is_premium: false, nation: Nation::Germany, @@ -1223,7 +1271,7 @@ pub static GENERATED: phf::Map = phf::phf_map! { }, 19985_u32 => Vehicle { tank_id: 19985, - name: Cow::Borrowed("Rheinmetall Skorpion G"), + name: Cow::Borrowed("Skorpion G"), tier: 8, is_premium: true, nation: Nation::Germany, @@ -1941,6 +1989,14 @@ pub static GENERATED: phf::Map = phf::phf_map! { nation: Nation::Japan, type_: TankType::Medium, }, + 26657_u32 => Vehicle { + tank_id: 26657, + name: Cow::Borrowed("ASTRON Rex 105 mm"), + tier: 8, + is_premium: true, + nation: Nation::Usa, + type_: TankType::Medium, + }, 2689_u32 => Vehicle { tank_id: 2689, name: Cow::Borrowed("Vickers Mk. F"), @@ -1957,6 +2013,14 @@ pub static GENERATED: phf::Map = phf::phf_map! { nation: Nation::Usa, type_: TankType::Light, }, + 27169_u32 => Vehicle { + tank_id: 27169, + name: Cow::Borrowed("Cyborg"), + tier: 6, + is_premium: true, + nation: Nation::Usa, + type_: TankType::Heavy, + }, 2817_u32 => Vehicle { tank_id: 2817, name: Cow::Borrowed("KV-1S"), @@ -3519,7 +3583,7 @@ pub static GENERATED: phf::Map = phf::phf_map! { }, 64801_u32 => Vehicle { tank_id: 64801, - name: Cow::Borrowed("T34 Independence"), + name: Cow::Borrowed("T34 (1776)"), tier: 8, is_premium: true, nation: Nation::Usa, @@ -3535,7 +3599,7 @@ pub static GENERATED: phf::Map = phf::phf_map! { }, 64849_u32 => Vehicle { tank_id: 64849, - name: Cow::Borrowed("AC 1 Sentinel"), + name: Cow::Borrowed("Sentinel\u{a0}AC I"), tier: 4, is_premium: true, nation: Nation::Uk, @@ -3567,7 +3631,7 @@ pub static GENERATED: phf::Map = phf::phf_map! { }, 65377_u32 => Vehicle { tank_id: 65377, - name: Cow::Borrowed("Type 3 Chi-Nu Kai"), + name: Cow::Borrowed("Type 3 Chi-Nu Kai Shinobi"), tier: 5, is_premium: true, nation: Nation::Japan, diff --git a/src/tankopedia/tankopedia.json b/src/tankopedia/tankopedia.json index 3fedad85..0b4b86ff 100644 --- a/src/tankopedia/tankopedia.json +++ b/src/tankopedia/tankopedia.json @@ -95,6 +95,14 @@ "nation": "other", "type": "heavyTank" }, + "10369": { + "tank_id": 10369, + "name": "Controcarro 3 Minotauro", + "tier": 10, + "is_premium": false, + "nation": "european", + "type": "AT-SPG" + }, "1041": { "tank_id": 1041, "name": "StuG III Ausf. G", @@ -135,6 +143,14 @@ "nation": "usa", "type": "mediumTank" }, + "10625": { + "tank_id": 10625, + "name": "Controcarro 1 Mk. 2", + "tier": 9, + "is_premium": false, + "nation": "european", + "type": "AT-SPG" + }, "1073": { "tank_id": 1073, "name": "T-34-1", @@ -175,6 +191,14 @@ "nation": "france", "type": "AT-SPG" }, + "10881": { + "tank_id": 10881, + "name": "Semovente Controcarro mod. 1964", + "tier": 8, + "is_premium": false, + "nation": "european", + "type": "AT-SPG" + }, "1089": { "tank_id": 1089, "name": "B1", @@ -223,6 +247,14 @@ "nation": "france", "type": "AT-SPG" }, + "11137": { + "tank_id": 11137, + "name": "Semovente Controcarro mod. 1956", + "tier": 7, + "is_premium": false, + "nation": "european", + "type": "AT-SPG" + }, "1121": { "tank_id": 1121, "name": "Type 5 Chi-Ri", @@ -271,6 +303,14 @@ "nation": "other", "type": "heavyTank" }, + "11393": { + "tank_id": 11393, + "name": "Semovente M43 Bassotto", + "tier": 6, + "is_premium": false, + "nation": "european", + "type": "AT-SPG" + }, "11521": { "tank_id": 11521, "name": "IS-8", @@ -311,6 +351,14 @@ "nation": "france", "type": "AT-SPG" }, + "11649": { + "tank_id": 11649, + "name": "Semovente M41", + "tier": 5, + "is_premium": false, + "nation": "european", + "type": "AT-SPG" + }, "11777": { "tank_id": 11777, "name": "KV-1", @@ -969,7 +1017,7 @@ }, "18449": { "tank_id": 18449, - "name": "Spähpanzer Ru 251", + "name": "Ru 251", "tier": 8, "is_premium": false, "nation": "germany", @@ -1185,7 +1233,7 @@ }, "19985": { "tank_id": 19985, - "name": "Rheinmetall Skorpion G", + "name": "Skorpion G", "tier": 8, "is_premium": true, "nation": "germany", @@ -1879,6 +1927,14 @@ "nation": "japan", "type": "mediumTank" }, + "26657": { + "tank_id": 26657, + "name": "ASTRON Rex 105 mm", + "tier": 8, + "is_premium": true, + "nation": "usa", + "type": "mediumTank" + }, "2689": { "tank_id": 2689, "name": "Vickers Mk. F", @@ -1887,6 +1943,22 @@ "nation": "european", "type": "lightTank" }, + "26913": { + "tank_id": 26913, + "name": "Frosty", + "tier": 6, + "is_premium": true, + "nation": "usa", + "type": "lightTank" + }, + "27169": { + "tank_id": 27169, + "name": "Cyborg", + "tier": 6, + "is_premium": true, + "nation": "usa", + "type": "heavyTank" + }, "2817": { "tank_id": 2817, "name": "KV-1S", @@ -2015,6 +2087,14 @@ "nation": "usa", "type": "heavyTank" }, + "3329": { + "tank_id": 3329, + "name": "MS-1 mod. 1", + "tier": 1, + "is_premium": false, + "nation": "ussr", + "type": "lightTank" + }, "3345": { "tank_id": 3345, "name": "Pz.Kpfw. 38 (t)", @@ -3401,7 +3481,7 @@ }, "64801": { "tank_id": 64801, - "name": "T34 Independence", + "name": "T34 (1776)", "tier": 8, "is_premium": true, "nation": "usa", @@ -3417,7 +3497,7 @@ }, "64849": { "tank_id": 64849, - "name": "AC 1 Sentinel", + "name": "Sentinel AC I", "tier": 4, "is_premium": true, "nation": "uk", @@ -3449,7 +3529,7 @@ }, "65377": { "tank_id": 65377, - "name": "Type 3 Chi-Nu Kai", + "name": "Type 3 Chi-Nu Kai Shinobi", "tier": 5, "is_premium": true, "nation": "japan", diff --git a/src/wargaming.rs b/src/wargaming.rs index 68405048..8468a369 100644 --- a/src/wargaming.rs +++ b/src/wargaming.rs @@ -95,7 +95,7 @@ impl WargamingApi { ], )?) .await - .with_context(|| format!("failed to search for accounts: `{}`", query)) + .with_context(|| format!("failed to search for accounts: `{query}`")) } /// See . @@ -124,7 +124,7 @@ impl WargamingApi { ], )?) .await - .with_context(|| format!("failed to get account infos: `{}`", account_id)) + .with_context(|| format!("failed to get account infos: `{account_id}`")) } /// See . @@ -143,7 +143,7 @@ impl WargamingApi { Ok(self .call_by_account(url, account_id) .await - .with_context(|| format!("failed to get tanks stats for #{}", account_id))? + .with_context(|| format!("failed to get tanks stats for #{account_id}"))? .unwrap_or_default()) } @@ -163,7 +163,7 @@ impl WargamingApi { Ok(self .call_by_account(url, account_id) .await - .with_context(|| format!("failed to get tanks achievements for #{}", account_id))? + .with_context(|| format!("failed to get tanks achievements for #{account_id}"))? .unwrap_or_default()) } @@ -172,7 +172,7 @@ impl WargamingApi { pub async fn get_tankopedia(&self) -> Result { info!("retrieving the tankopedia…"); self.call::(Url::parse_with_params( - "https://api.wotblitz.ru/wotb/encyclopedia/vehicles/", + "https://api.wotblitz.eu/wotb/encyclopedia/vehicles/", &[ ("application_id", self.application_id.as_str()), ("language", "en"), diff --git a/src/wargaming/models/tank_id.rs b/src/wargaming/models/tank_id.rs index 626a96eb..070d34af 100644 --- a/src/wargaming/models/tank_id.rs +++ b/src/wargaming/models/tank_id.rs @@ -5,7 +5,7 @@ pub type TankId = u32; /// Converts the API tank ID to the client tank ID. pub fn to_client_id(tank_id: TankId) -> Result { - Ok(Nation::from_tank_id(tank_id)?.get_id() + (tank_id as u32 >> 8)) + Ok(Nation::from_tank_id(tank_id)?.get_id() + (tank_id >> 8)) } #[cfg(test)] diff --git a/src/wargaming/models/vehicle.rs b/src/wargaming/models/vehicle.rs index 276514b3..71dadee5 100644 --- a/src/wargaming/models/vehicle.rs +++ b/src/wargaming/models/vehicle.rs @@ -24,7 +24,7 @@ impl Vehicle { pub fn new_hardcoded(tank_id: TankId) -> Self { Self { tank_id, - name: Cow::Owned(format!("#{}", tank_id)), + name: Cow::Owned(format!("#{tank_id}")), tier: 0, is_premium: false, type_: TankType::Unknown, diff --git a/src/web/partials.rs b/src/web/partials.rs index 73a31984..81f04408 100644 --- a/src/web/partials.rs +++ b/src/web/partials.rs @@ -190,7 +190,7 @@ pub fn vehicle_title(vehicle: &wargaming::Vehicle, locale: &Locale) -> Result Result Markup { html! { span title=(value) { - (format!("{:.1$}", value, precision)) + (format!("{value:.precision$}")) } } } diff --git a/src/web/tracking_code.rs b/src/web/tracking_code.rs index f2db3e8a..86e5df40 100644 --- a/src/web/tracking_code.rs +++ b/src/web/tracking_code.rs @@ -21,8 +21,7 @@ impl TrackingCode { if let Some(measurement_id) = &opts.gtag { write!( code, - r#" "#, - measurement_id, + r#" "#, )?; }; Ok(Self(PreEscaped(code))) diff --git a/src/web/views/player.rs b/src/web/views/player.rs index d64aa138..856fbd18 100644 --- a/src/web/views/player.rs +++ b/src/web/views/player.rs @@ -54,7 +54,7 @@ pub async fn post( ) -> poem::Result { let cookie_preferences = UpdateDisplayPreferences::from(cookies); cookies::Builder::new(UpdateDisplayPreferences::COOKIE_NAME) - .value(&DisplayPreferences::from(cookie_preferences + update_preferences)) + .value(DisplayPreferences::from(cookie_preferences + update_preferences)) .expires_in(Duration::weeks(4)) .set_path("/") .add_to(cookies); @@ -203,6 +203,13 @@ pub async fn get( } } } + + th { + span.icon-text.is-flex-wrap-nowrap { + span.icon { i.fas.fa-truck-monster {} } + span { (locale.text("title-vehicle")?) } + } + } } }; let markup = html! { @@ -434,7 +441,7 @@ pub async fn get( p.heading { (locale.text("title-change")?) } @let delta = view_model.stats_delta.rating.delta(); p.title.(SemaphoreClass::<_, f64>::new(delta)) title=(delta) { - (format!("{:+.0}", delta)) + (format!("{delta:+.0}")) } } } @@ -443,7 +450,7 @@ pub async fn get( p.heading { (locale.text("title-per-battle")?) } @let delta_per_battle = view_model.stats_delta.rating.delta_per_battle(); p.title.(SemaphoreClass::new(delta_per_battle)) title=(delta_per_battle) { - (format!("{:+.0}", delta_per_battle)) + (format!("{delta_per_battle:+.0}")) } } } @@ -957,7 +964,8 @@ fn render_tank_tr( .has-background-danger-light[thumbs_down_probability > confidence_level] .has-background-success-light[(1.0 - thumbs_down_probability > confidence_level)] { - (vehicle_th(&vehicle, locale)?) + @let vehicle_th = vehicle_th(&vehicle, locale)?; + (vehicle_th) td.has-text-centered.is-white-space-nowrap { @match vehicle.type_ { @@ -1073,6 +1081,8 @@ fn render_tank_tr( span { (render_percentage(survival_rate)) } } } + + (vehicle_th) } }; Ok(markup) diff --git a/src/web/views/player/display_preferences.rs b/src/web/views/player/display_preferences.rs index 41ca3a4f..c6b615ea 100644 --- a/src/web/views/player/display_preferences.rs +++ b/src/web/views/player/display_preferences.rs @@ -81,7 +81,7 @@ impl From for DisplayPreferences { Self { period: update.period.unwrap_or(time::Duration::from_secs(86400)), confidence_level_percentage, - confidence_level: confidence_level_percentage as f64 / 100.0, + confidence_level: confidence_level_percentage / 100.0, target_victory_ratio_percentage, target_victory_ratio: target_victory_ratio_percentage / 100.0, }