Skip to content

Commit 4d18f5a

Browse files
authored
fix mlb deser optional field (#68)
* fix mlb deser optional field * suppress clippy lint
1 parent abd0ccc commit 4d18f5a

File tree

4 files changed

+9
-6
lines changed

4 files changed

+9
-6
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ authors = ["tarkah <admin@tarkah.dev>"]
55
edition = "2018"
66

77
[dependencies]
8-
stats-api = { git = "https://github.com/tarkah/stats-api", rev = "d1834a7cb76da175b6d8f7505ef239f1eff0203e" }
8+
stats-api = { git = "https://github.com/tarkah/stats-api", rev = "9f6948dc786b66251a8bd9ad28d7277ac41af413" }
99

1010
failure = "0.1"
1111
chrono = "0.4"

src/api/model.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ pub struct Team {
77
pub id: u32,
88
pub name: String,
99
pub link: String,
10-
pub abbreviation: String,
10+
pub abbreviation: Option<String>,
1111
#[serde(default)]
1212
pub team_name: String,
1313
pub location_name: Option<String>,
@@ -160,6 +160,8 @@ pub struct GameContentArticleMediaImageCutDetail {
160160
pub src: String,
161161
}
162162

163+
#[allow(clippy::unknown_clippy_lints)]
164+
#[allow(clippy::unnecessary_wraps)]
163165
fn fail_as_none<'de, D, T>(de: D) -> Result<Option<T>, D::Error>
164166
where
165167
D: serde::Deserializer<'de>,

src/stream.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ impl LazyStream {
8888
if self
8989
.teams
9090
.iter()
91-
.any(|team| team.abbreviation == team_abbrev)
91+
.any(|team| team.abbreviation.as_deref() == Some(team_abbrev))
9292
{
9393
Ok(())
9494
} else {
@@ -98,7 +98,8 @@ impl LazyStream {
9898

9999
pub fn game_with_team_abbrev(&self, team_abbrev: &str) -> Option<Game> {
100100
let game_idx = self.games.iter().position(|game| {
101-
game.home_team.abbreviation == team_abbrev || game.away_team.abbreviation == team_abbrev
101+
game.home_team.abbreviation.as_deref() == Some(team_abbrev)
102+
|| game.away_team.abbreviation.as_deref() == Some(team_abbrev)
102103
});
103104
if let Some(index) = game_idx {
104105
Some(self.games[index].clone())
@@ -265,7 +266,7 @@ impl Game {
265266

266267
let mut feed_type: FeedType = if let Some(feed_type) = feed_type {
267268
feed_type
268-
} else if self.home_team.abbreviation == team_abbrev {
269+
} else if self.home_team.abbreviation.as_deref() == Some(team_abbrev) {
269270
FeedType::Home
270271
} else {
271272
FeedType::Away

0 commit comments

Comments
 (0)