mirror of
https://codeberg.org/icewind/ugc-scaper.git
synced 2026-06-03 10:14:11 +02:00
region optional
This commit is contained in:
parent
335c75cb12
commit
dc0f3e9f0f
11 changed files with 36 additions and 15 deletions
4
api-server/Cargo.lock
generated
4
api-server/Cargo.lock
generated
|
|
@ -1964,7 +1964,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ugc-scraper"
|
||||
version = "0.5.0"
|
||||
source = "git+https://github.com/icewind1991/ugc-scaper#f79c02a010ee5ec572901b4eb5b14067b5ab45a9"
|
||||
source = "git+https://github.com/icewind1991/ugc-scaper#b290e2f83db161e2a7bcf4e199400226d56a2076"
|
||||
dependencies = [
|
||||
"regex",
|
||||
"reqwest",
|
||||
|
|
@ -1979,7 +1979,7 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "ugc-scraper-types"
|
||||
version = "0.2.0"
|
||||
source = "git+https://github.com/icewind1991/ugc-scaper#f79c02a010ee5ec572901b4eb5b14067b5ab45a9"
|
||||
source = "git+https://github.com/icewind1991/ugc-scaper#b290e2f83db161e2a7bcf4e199400226d56a2076"
|
||||
dependencies = [
|
||||
"serde",
|
||||
"steamid-ng",
|
||||
|
|
|
|||
19
archiver/migrations/20250414181350_teams.sql
Normal file
19
archiver/migrations/20250414181350_teams.sql
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
CREATE TYPE region AS ENUM ('europe', 'north-america', 'south-america', 'asia', 'australia');
|
||||
CREATE TYPE game_mode AS ENUM ('highlander', 'sixes', 'fours', 'ultiduo');
|
||||
|
||||
CREATE TABLE teams
|
||||
(
|
||||
id INTEGER NOT NULL,
|
||||
name VARCHAR NOT NULL,
|
||||
image VARCHAR NOT NULL,
|
||||
form
|
||||
);
|
||||
|
||||
CREATE UNIQUE INDEX matches_id_idx
|
||||
ON matches USING BTREE (id);
|
||||
|
||||
CREATE INDEX matches_home_idx
|
||||
ON matches USING BTREE (team_home);
|
||||
|
||||
CREATE INDEX matches_away_idx
|
||||
ON matches USING BTREE (team_away);
|
||||
|
|
@ -181,11 +181,7 @@ impl Parser for TeamParser {
|
|||
let region = division
|
||||
.split(' ')
|
||||
.find_map(|part| Region::from_str(part).ok())
|
||||
.or_else(|| Region::from_str(&division).ok())
|
||||
.ok_or_else(|| ParseError::InvalidText {
|
||||
text: division.clone(),
|
||||
role: "team region",
|
||||
})?;
|
||||
.or_else(|| Region::from_str(&division).ok());
|
||||
|
||||
let timezone = select_text(root, &self.selector_team_timezone).map(String::from);
|
||||
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ expression: parsed
|
|||
"tag": "Melting Pot",
|
||||
"image": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/f7/f75809d7774c917be9883370d772d3099bfe457d_full.jpg",
|
||||
"format": "9v9",
|
||||
"region": "Europe",
|
||||
"region": "europe",
|
||||
"timezone": "West-Euro",
|
||||
"steam_group": "http://steamcommunity.com/groups/Melintongpotsss",
|
||||
"division": "Euro Platinum",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ expression: parsed
|
|||
"tag": "Europe",
|
||||
"image": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/09/096a30b1025c586f9d41c686077129f6e86998d0_full.jpg",
|
||||
"format": "6v6",
|
||||
"region": "Europe",
|
||||
"region": "europe",
|
||||
"timezone": "West-Euro",
|
||||
"steam_group": null,
|
||||
"division": "Europe",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ expression: parsed
|
|||
"tag": "PNKTSU",
|
||||
"image": "clan_avatars/32437_thumbnail.jpg",
|
||||
"format": "9v9",
|
||||
"region": "NorthAmerica",
|
||||
"region": "north-america",
|
||||
"timezone": null,
|
||||
"steam_group": "https://steamcommunity.com/groups/xyxxx-",
|
||||
"division": "North America",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ expression: parsed
|
|||
"tag": "-Xe-",
|
||||
"image": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/db/dbabbd8bab7ccf6d27a9d4ca2e73a76e085bb201_full.jpg",
|
||||
"format": "9v9",
|
||||
"region": "Europe",
|
||||
"region": "europe",
|
||||
"timezone": "West-Euro",
|
||||
"steam_group": "https://steamcommunity.com/groups/XenonxTF2",
|
||||
"division": "Euro Platinum",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ expression: parsed
|
|||
"tag": "-BB-",
|
||||
"image": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/4c/4c75e24cd642d648ae3105fc9e66580e6064e393_full.jpg",
|
||||
"format": "4v4",
|
||||
"region": "NorthAmerica",
|
||||
"region": "north-america",
|
||||
"timezone": "East",
|
||||
"steam_group": "http://steamcommunity.com/groups/banananana_boat",
|
||||
"division": "Gold N.Amer",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ expression: parsed
|
|||
"tag": "#1TF2Team",
|
||||
"image": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/b9/b9cc1e4949f5e6d0364f9ee59a13cc931fd3aab1_full.jpg",
|
||||
"format": "9v9",
|
||||
"region": "NorthAmerica",
|
||||
"region": "north-america",
|
||||
"timezone": "East",
|
||||
"steam_group": "http://steamcommunity.com/groups/NumberOneTF2Team",
|
||||
"division": "Main NA",
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ expression: parsed
|
|||
"tag": "Grand Meister",
|
||||
"image": "https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/d7/d71ff4e1e2635c3d7c1be8d96bc40b499c665aad_full.jpg",
|
||||
"format": "9v9",
|
||||
"region": "NorthAmerica",
|
||||
"region": "north-america",
|
||||
"timezone": null,
|
||||
"steam_group": "http://steamcommunity.com/groups/BARNEYANDTHEGANKS",
|
||||
"division": "NA Platinum",
|
||||
|
|
|
|||
|
|
@ -115,7 +115,7 @@ pub struct Team {
|
|||
pub tag: String,
|
||||
pub image: String,
|
||||
pub format: GameMode,
|
||||
pub region: Region,
|
||||
pub region: Option<Region>,
|
||||
pub timezone: Option<String>,
|
||||
pub steam_group: Option<String>,
|
||||
pub division: String,
|
||||
|
|
@ -280,6 +280,7 @@ pub struct InvalidGameMode {
|
|||
#[derive(Debug, Clone, Copy)]
|
||||
pub enum GameMode {
|
||||
Highlander,
|
||||
Eights,
|
||||
Sixes,
|
||||
Fours,
|
||||
Ultiduo,
|
||||
|
|
@ -291,11 +292,13 @@ impl FromStr for GameMode {
|
|||
fn from_str(s: &str) -> Result<Self, Self::Err> {
|
||||
match s {
|
||||
"9v9" => Ok(GameMode::Highlander),
|
||||
"8v8" => Ok(GameMode::Eights),
|
||||
"6v6" => Ok(GameMode::Sixes),
|
||||
"4v4" => Ok(GameMode::Fours),
|
||||
"2v2" => Ok(GameMode::Ultiduo),
|
||||
"TF2 Highlander" => Ok(GameMode::Highlander),
|
||||
"ASIA TF2-H" => Ok(GameMode::Highlander),
|
||||
"TF2 8vs8" => Ok(GameMode::Eights),
|
||||
"TF2 6vs6" => Ok(GameMode::Sixes),
|
||||
"TF2 4vs4" => Ok(GameMode::Fours),
|
||||
"TF2 2vs2" => Ok(GameMode::Ultiduo),
|
||||
|
|
@ -310,6 +313,7 @@ impl GameMode {
|
|||
pub fn letter(&self) -> char {
|
||||
match self {
|
||||
GameMode::Highlander => 'h',
|
||||
GameMode::Eights => '8',
|
||||
GameMode::Sixes => '6',
|
||||
GameMode::Fours => '4',
|
||||
GameMode::Ultiduo => '2',
|
||||
|
|
@ -319,6 +323,7 @@ impl GameMode {
|
|||
fn as_str(&self) -> &'static str {
|
||||
match self {
|
||||
GameMode::Highlander => "9v9",
|
||||
GameMode::Eights => "8v8",
|
||||
GameMode::Sixes => "6v6",
|
||||
GameMode::Fours => "4v4",
|
||||
GameMode::Ultiduo => "2v2",
|
||||
|
|
@ -358,6 +363,7 @@ pub struct InvalidRegion {
|
|||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Copy, Clone, Debug)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
pub enum Region {
|
||||
Europe,
|
||||
NorthAmerica,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue