fix(meta,api): detail ratings are optional too
This commit is contained in:
@@ -46,7 +46,8 @@ pub struct MovieMetadata {
|
|||||||
pub status: String,
|
pub status: String,
|
||||||
pub poster_path: Option<String>,
|
pub poster_path: Option<String>,
|
||||||
pub backdrop_path: Option<String>,
|
pub backdrop_path: Option<String>,
|
||||||
pub vote_average: f64,
|
/// Absent when TMDB has no votes for the title (#156).
|
||||||
|
pub vote_average: Option<f64>,
|
||||||
pub vote_count: u32,
|
pub vote_count: u32,
|
||||||
pub homepage: Option<String>,
|
pub homepage: Option<String>,
|
||||||
/// §9.6 links out to `IMDb` for movies.
|
/// §9.6 links out to `IMDb` for movies.
|
||||||
@@ -68,7 +69,8 @@ pub struct SeriesMetadata {
|
|||||||
pub status: String,
|
pub status: String,
|
||||||
pub poster_path: Option<String>,
|
pub poster_path: Option<String>,
|
||||||
pub backdrop_path: Option<String>,
|
pub backdrop_path: Option<String>,
|
||||||
pub vote_average: f64,
|
/// Absent when TMDB has no votes for the title (#156).
|
||||||
|
pub vote_average: Option<f64>,
|
||||||
pub vote_count: u32,
|
pub vote_count: u32,
|
||||||
pub homepage: Option<String>,
|
pub homepage: Option<String>,
|
||||||
/// §9.6 links out to TVDB for series.
|
/// §9.6 links out to TVDB for series.
|
||||||
|
|||||||
@@ -223,7 +223,10 @@ pub struct MovieDetail {
|
|||||||
pub genres: Vec<Genre>,
|
pub genres: Vec<Genre>,
|
||||||
pub backdrop_path: Option<String>,
|
pub backdrop_path: Option<String>,
|
||||||
pub poster_path: Option<String>,
|
pub poster_path: Option<String>,
|
||||||
pub vote_average: f64,
|
/// Zero normalised away, like [`Movie::vote_average`]: TMDB sends `0`
|
||||||
|
/// where "no votes yet" is meant, and a detail page must not show it as
|
||||||
|
/// a rating.
|
||||||
|
pub vote_average: Option<f64>,
|
||||||
pub vote_count: u32,
|
pub vote_count: u32,
|
||||||
pub homepage: Option<String>,
|
pub homepage: Option<String>,
|
||||||
pub status: String,
|
pub status: String,
|
||||||
@@ -244,7 +247,10 @@ pub struct SeriesDetail {
|
|||||||
pub genres: Vec<Genre>,
|
pub genres: Vec<Genre>,
|
||||||
pub backdrop_path: Option<String>,
|
pub backdrop_path: Option<String>,
|
||||||
pub poster_path: Option<String>,
|
pub poster_path: Option<String>,
|
||||||
pub vote_average: f64,
|
/// Zero normalised away, like [`Movie::vote_average`]: TMDB sends `0`
|
||||||
|
/// where "no votes yet" is meant, and a detail page must not show it as
|
||||||
|
/// a rating.
|
||||||
|
pub vote_average: Option<f64>,
|
||||||
pub vote_count: u32,
|
pub vote_count: u32,
|
||||||
pub homepage: Option<String>,
|
pub homepage: Option<String>,
|
||||||
pub status: String,
|
pub status: String,
|
||||||
@@ -771,7 +777,7 @@ impl From<RawMovieDetail> for MovieDetail {
|
|||||||
.collect(),
|
.collect(),
|
||||||
backdrop_path: non_empty(raw.backdrop_path),
|
backdrop_path: non_empty(raw.backdrop_path),
|
||||||
poster_path: non_empty(raw.poster_path),
|
poster_path: non_empty(raw.poster_path),
|
||||||
vote_average: raw.vote_average,
|
vote_average: rating(raw.vote_average),
|
||||||
vote_count: raw.vote_count,
|
vote_count: raw.vote_count,
|
||||||
homepage: non_empty(raw.homepage),
|
homepage: non_empty(raw.homepage),
|
||||||
status: raw.status,
|
status: raw.status,
|
||||||
@@ -799,7 +805,7 @@ impl From<RawSeriesDetail> for SeriesDetail {
|
|||||||
.collect(),
|
.collect(),
|
||||||
backdrop_path: non_empty(raw.backdrop_path),
|
backdrop_path: non_empty(raw.backdrop_path),
|
||||||
poster_path: non_empty(raw.poster_path),
|
poster_path: non_empty(raw.poster_path),
|
||||||
vote_average: raw.vote_average,
|
vote_average: rating(raw.vote_average),
|
||||||
vote_count: raw.vote_count,
|
vote_count: raw.vote_count,
|
||||||
homepage: non_empty(raw.homepage),
|
homepage: non_empty(raw.homepage),
|
||||||
status: raw.status,
|
status: raw.status,
|
||||||
|
|||||||
@@ -613,7 +613,7 @@ async fn movie_detail_parses_the_rich_fields() {
|
|||||||
assert_eq!(movie.genres[0].name, "Science Fiction");
|
assert_eq!(movie.genres[0].name, "Science Fiction");
|
||||||
assert!(movie.poster_path.is_some());
|
assert!(movie.poster_path.is_some());
|
||||||
assert!(movie.backdrop_path.is_some());
|
assert!(movie.backdrop_path.is_some());
|
||||||
assert!((movie.vote_average - 8.152).abs() < f64::EPSILON);
|
assert!((movie.vote_average.expect("rated") - 8.152).abs() < f64::EPSILON);
|
||||||
assert_eq!(movie.vote_count, 6_249);
|
assert_eq!(movie.vote_count, 6_249);
|
||||||
assert_eq!(movie.homepage.as_deref(), Some("https://www.dunemovie.com"));
|
assert_eq!(movie.homepage.as_deref(), Some("https://www.dunemovie.com"));
|
||||||
assert_eq!(movie.status, "Released");
|
assert_eq!(movie.status, "Released");
|
||||||
|
|||||||
Reference in New Issue
Block a user