Skip to content

Commit

Permalink
use regex for map to reuse mapping from other parts of gametools and …
Browse files Browse the repository at this point in the history
…fix operations
  • Loading branch information
zefanjajobse committed Feb 17, 2024
1 parent 6dc4636 commit a3af434
Show file tree
Hide file tree
Showing 3 changed files with 82 additions and 87 deletions.
15 changes: 8 additions & 7 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ anyhow = "1.0"
mongodb = "2.8"
futures = "0.3"
chrono = "0.4"
influxdb2 = "0.4"
influxdb2 = "0.5"
influxdb2-structmap = "0.2"
num-traits = "0.2"
serde_json = "1.0"
Expand All @@ -20,7 +20,7 @@ serde_derive = "1.0"
questdb-rs = "3.1"
sqlx = { version = "0.7", features = ["runtime-tokio", "postgres", "time"] }
time = { version = "0.3", features = ["macros", "rand"] }

regex = "1.10"

[dependencies.clickhouse]
version = "0.11"
Expand All @@ -35,11 +35,11 @@ version = "0.3"
features = ["tls"]

[dependencies.bson]
version = "2.8"
version = "2.9"
features = ["chrono-0_4"]

[dependencies.tokio]
version = "1.35"
version = "1.36"
features = ["full"]

[dependencies.bf_sparta]
Expand Down
146 changes: 70 additions & 76 deletions src/gatherer/marne.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ use crate::{
},
};
use chrono::Utc;
use regex::Regex;
use sqlx::PgPool;
use std::collections::HashMap;

Expand Down Expand Up @@ -42,86 +43,77 @@ async fn server_list_to_sum(
HashMap<String, Vec<server_info::ServerInfo>>,
) {
let maps = HashMap::from([
("Levels/MP/MP_Amiens/MP_Amiens", "Amiens"),
("Levels/MP/MP_Chateau/MP_Chateau", "Ballroom Blitz"),
("Levels/MP/MP_Desert/MP_Desert", "Sinai Desert"),
("Levels/MP/MP_FaoFortress/MP_FaoFortress", "Fao Fortress"),
("Levels/MP/MP_Forest/MP_Forest", "Argonne Forest"),
("Levels/MP/MP_ItalianCoast/MP_ItalianCoast", "Empire's Edge"),
("Levels/MP/MP_MountainFort/MP_MountainFort", "Monte Grappa"),
("Levels/MP/MP_Scar/MP_Scar", "St Quentin Scar"),
("Levels/MP/MP_Suez/MP_Suez", "Suez"),
("Xpack0/Levels/MP/MP_Giant/MP_Giant", "Giant's Shadow"),
("Xpack1/Levels/MP_Fields/MP_Fields", "Soissons"),
("Xpack1/Levels/MP_Graveyard/MP_Graveyard", "Rupture"),
("Xpack1/Levels/MP_Underworld/MP_Underworld", "Fort De Vaux"),
("Xpack1/Levels/MP_Verdun/MP_Verdun", "Verdun Heights"),
(
"Xpack1-3/Levels/MP_ShovelTown/MP_ShovelTown",
"Prise de Tahure",
),
("Xpack1-3/Levels/MP_Trench/MP_Trench", "Nivelle Nights"),
("Xpack2/Levels/MP/MP_Bridge/MP_Bridge", "Brusilov Keep"),
("Xpack2/Levels/MP/MP_Islands/MP_Islands", "Albion"),
("Xpack2/Levels/MP/MP_Ravines/MP_Ravines", "Łupków Pass"),
("Xpack2/Levels/MP/MP_Tsaritsyn/MP_Tsaritsyn", "Tsaritsyn"),
("Xpack2/Levels/MP/MP_Valley/MP_Valley", "Galicia"),
("Xpack2/Levels/MP/MP_Volga/MP_Volga", "Volga River"),
("Xpack3/Levels/MP/MP_Beachhead/MP_Beachhead", "Cape Helles"),
("Xpack3/Levels/MP/MP_Harbor/MP_Harbor", "Zeebrugge"),
("Xpack3/Levels/MP/MP_Naval/MP_Naval", "Heligoland Bight"),
("Xpack3/Levels/MP/MP_Ridge/MP_Ridge", "Achi Baba"),
("Xpack4/Levels/MP/MP_Alps/MP_Alps", "Razor's Edge"),
("Xpack4/Levels/MP/MP_Blitz/MP_Blitz", "London Calling"),
("Xpack4/Levels/MP/MP_Hell/MP_Hell", "Passchendaele"),
(
"Xpack4/Levels/MP/MP_London/MP_London",
"London Calling: Scourge",
),
("Xpack4/Levels/MP/MP_Offensive/MP_Offensive", "River Somme"),
("Xpack4/Levels/MP/MP_River/MP_River", "Caporetto"),
("MP_Amiens", "Amiens"),
("MP_Chateau", "Ballroom Blitz"),
("MP_Desert", "Sinai Desert"),
("MP_FaoFortress", "Fao Fortress"),
("MP_Forest", "Argonne Forest"),
("MP_ItalianCoast", "Empire's Edge"),
("MP_MountainFort", "Monte Grappa"),
("MP_Scar", "St Quentin Scar"),
("MP_Suez", "Suez"),
("MP_Giant", "Giant's Shadow"),
("MP_Fields", "Soissons"),
("MP_Graveyard", "Rupture"),
("MP_Underworld", "Fort De Vaux"),
("MP_Verdun", "Verdun Heights"),
("MP_ShovelTown", "Prise de Tahure"),
("MP_Trench", "Nivelle Nights"),
("MP_Bridge", "Brusilov Keep"),
("MP_Islands", "Albion"),
("MP_Ravines", "Łupków Pass"),
("MP_Tsaritsyn", "Tsaritsyn"),
("MP_Valley", "Galicia"),
("MP_Volga", "Volga River"),
("MP_Beachhead", "Cape Helles"),
("MP_Harbor", "Zeebrugge"),
("MP_Naval", "Heligoland Bight"),
("MP_Ridge", "Achi Baba"),
("MP_Alps", "Razor's Edge"),
("MP_Blitz", "London Calling"),
("MP_Hell", "Passchendaele"),
("MP_London", "London Calling: Scourge"),
("MP_Offensive", "River Somme"),
("MP_River", "Caporetto"),
// BFV
// MP_ArcticFjell: "Fjell 652",
// MP_ArcticFjord: "Narvik",
("Levels/MP/MP_Arras/MP_Arras", "Arras"),
// MP_Devastation: "Devastation",
// MP_Escaut: "twisted steel",
// MP_Foxhunt: "Aerodrome",
// MP_Halfaya: "Hamada",
// MP_Rotterdam: "Rotterdam",
// MP_Hannut: "Panzerstorm",
// MP_Crete: "Mercury",
(
"Live/Greece/Kalamas/Levels/MP/MP_Kalamas/MP_Kalamas",
"Marita",
),
// MP_Provence: "Provence",
// MP_SandAndSea: "Al sudan",
// MP_Bunker: "Operation Underground",
("Live/Pacific/Levels/MP/MP_IwoJima/MP_IwoJima", "Iwo jima"),
// MP_TropicIslands: "Pacific storm",
// MP_WakeIsland: "Wake island",
// MP_Jungle: "Solomon islands",
// MP_Libya: "Al marj encampment",
// MP_Norway: "lofoten islands",
("MP_ArcticFjell", "Fjell 652"),
("MP_ArcticFjord", "Narvik"),
("MP_Arras", "Arras"),
("MP_Devastation", "Devastation"),
("MP_Escaut", "twisted steel"),
("MP_Foxhunt", "Aerodrome"),
("MP_Halfaya", "Hamada"),
("MP_Rotterdam", "Rotterdam"),
("MP_Hannut", "Panzerstorm"),
("MP_Crete", "Mercury"),
("MP_Kalamas", "Marita"),
("MP_Provence", "Provence"),
("MP_SandAndSea", "Al sudan"),
("MP_Bunker", "Operation Underground"),
("MP_IwoJima", "Iwo jima"),
("MP_TropicIslands", "Pacific storm"),
("MP_WakeIsland", "Wake island"),
("MP_Jungle", "Solomon islands"),
("MP_Libya", "Al marj encampment"),
("MP_Norway", "lofoten islands"),
// bfv special maps
// DK_Norway: "Halvoy",
// MP_Escaut_US: "Twisted Steel US",
// MP_Hannut_US: "Panzerstorm US",
// MP_GOps_Chapter2_Arras: "Arras (Chapter 2)",
// MP_WE_Fortress_Devastation: "Devastation (Fortress)",
// MP_WE_Fortress_Halfaya: "Hamada (Fortress)",
// MP_WE_Grind_ArcticFjord: "Narvik (Grind)",
// MP_WE_Grind_Devastation: "Devastation (Grind)",
// MP_WE_Grind_Escaut: "Twisted Steel (Grind)",
// MP_WE_Grind_Rotterdam: "Rotterdam (Grind)",
("DK_Norway", "Halvoy"),
("MP_Escaut_US", "Twisted Steel US"),
("MP_Hannut_US", "Panzerstorm US"),
("MP_GOps_Chapter2_Arras", "Arras (Chapter 2)"),
("MP_WE_Fortress_Devastation", "Devastation (Fortress)"),
("MP_WE_Fortress_Halfaya", "Hamada (Fortress)"),
("MP_WE_Grind_ArcticFjord", "Narvik (Grind)"),
("MP_WE_Grind_Devastation", "Devastation (Grind)"),
("MP_WE_Grind_Escaut", "Twisted Steel (Grind)"),
("MP_WE_Grind_Rotterdam", "Rotterdam (Grind)"),
]);

let modes = HashMap::from([
("Conquest0", "Conquest"),
("Rush0", "Rush"),
("BreakThrough0", "Shock Operations"),
("BreakThroughLarge0", "Operations"),
("BreakthroughLarge0", "Operations"),
("Possession0", "War pigeons"),
("TugOfWar0", "Frontlines"),
("AirAssault0", "Air assault"),
Expand Down Expand Up @@ -176,10 +168,12 @@ async fn server_list_to_sum(
.get(&server.game_mode[..])
.unwrap_or(&&server.game_mode[..])
.to_string();
let map = maps
.get(&server.map_name[..])
.unwrap_or(&&server.map_name[..])
.to_string();

let internal_map = match Regex::new(r"[^\/]+$").unwrap().find(&server.map_name[..]) {
Some(location) => location.as_str(),
None => &server.map_name[..],
};
let map = maps.get(internal_map).unwrap_or(&internal_map).to_string();

regions
.entry(server_region.clone())
Expand Down

0 comments on commit a3af434

Please sign in to comment.