handle team matches without match links

This commit is contained in:
Robin Appelman 2025-04-20 15:28:31 +02:00
commit cc3ea78778
6 changed files with 6052 additions and 2743 deletions

View file

@ -179,8 +179,8 @@ impl Parser for TeamMatchesParser {
})
.transpose()?;
let result = match (opponent, points, points_opponent) {
(Some(opponent), Some(point), Some(points_opponent)) => {
let result = match (opponent, points, points_opponent, id) {
(Some(opponent), Some(point), Some(points_opponent), Some(_)) => {
MatchResult::Played {
id: id.ok_or(ParseError::ElementNotFound {
selector: SELECTOR_SEASON_MATCH_PAGE,
@ -193,7 +193,7 @@ impl Parser for TeamMatchesParser {
match_points_opponent: points_opponent,
}
}
(Some(opponent), None, None) => MatchResult::Pending {
(Some(opponent), None, None, Some(_)) => MatchResult::Pending {
id: id.ok_or(ParseError::ElementNotFound {
selector: SELECTOR_SEASON_MATCH_PAGE,
role: "match page link",
@ -202,6 +202,7 @@ impl Parser for TeamMatchesParser {
score,
score_opponent,
},
(Some(opponent), _, _, None) => MatchResult::Unknown { opponent },
_ => MatchResult::ByeWeek,
};
Ok(TeamSeasonMatch {

File diff suppressed because it is too large Load diff

View file

@ -61,6 +61,7 @@ fn test_parse_team_roster_history_html(input: &str, name: &str) {
}
#[test_case("team_matches_7861.html", "team_matches")]
#[test_case("team_matches_2157.html", "team_matches_old")]
#[cfg(feature = "serde")]
fn test_parse_team_matches_html(input: &str, name: &str) {
let body = read_to_string(format!("tests/data/{input}")).unwrap();

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,147 @@
---
source: tests/snapshot.rs
expression: parsed
---
[
{
"season": 1,
"matches": [
{
"division": "Steel",
"week": 1,
"date": "Sun Oct 28",
"side": "visiting",
"result": {
"state": "unknown",
"opponent": {
"name": "[$0.00]",
"id": 2137
}
},
"map": "cp_gravelpit"
},
{
"division": "Platinum",
"week": 2,
"date": "Sun Nov 04",
"side": "home",
"result": {
"state": "unknown",
"opponent": {
"name": "-DeX-",
"id": 2130
}
},
"map": "cp_gravelpit"
},
{
"division": "Platinum",
"week": 3,
"date": "Sun Nov 11",
"side": "home",
"result": {
"state": "unknown",
"opponent": {
"name": "[UGS]",
"id": 2127
}
},
"map": "cp_dustbowl"
},
{
"division": "Platinum",
"week": 4,
"date": "Sun Nov 18",
"side": "home",
"result": {
"state": "bye_week"
},
"map": "cp_dustbowl"
},
{
"division": "Platinum",
"week": 6,
"date": "Mon Dec 10",
"side": "home",
"result": {
"state": "unknown",
"opponent": {
"name": ".tKd",
"id": 2169
}
},
"map": "ctf_impact"
},
{
"division": "Platinum",
"week": 7,
"date": "Mon Dec 17",
"side": "visiting",
"result": {
"state": "unknown",
"opponent": {
"name": "[FOoM]",
"id": 2172
}
},
"map": "cp_science2"
},
{
"division": "Platinum",
"week": 11,
"date": "Mon Jan 14",
"side": "home",
"result": {
"state": "unknown",
"opponent": {
"name": "[SWAT]",
"id": 2188
}
},
"map": "cp_junction"
},
{
"division": "Platinum",
"week": 12,
"date": "Mon Jan 21",
"side": "home",
"result": {
"state": "unknown",
"opponent": {
"name": "[FOoM]",
"id": 2172
}
},
"map": "cp_castle3"
},
{
"division": "Platinum",
"week": 13,
"date": "Mon Jan 28",
"side": "home",
"result": {
"state": "unknown",
"opponent": {
"name": "[=1=]",
"id": 2197
}
},
"map": "cp_dustbowl"
},
{
"division": "Platinum",
"week": 14,
"date": "Mon Feb 04",
"side": "home",
"result": {
"state": "unknown",
"opponent": {
"name": "[FOoM]",
"id": 2172
}
},
"map": "cp_science"
}
]
}
]

View file

@ -298,6 +298,9 @@ pub enum MatchResult {
score_opponent: u8,
},
ByeWeek,
Unknown {
opponent: TeamRef,
},
}
impl MatchResult {
@ -305,7 +308,7 @@ impl MatchResult {
match self {
MatchResult::Played { id, .. } => Some(*id),
MatchResult::Pending { id, .. } => Some(*id),
MatchResult::ByeWeek => None,
_ => None,
}
}
}