fix(meta): detail types and metadata endpoint carry unrated as null
MovieDetail and SeriesDetail normalise TMDB's vote_average: 0 to None like the persisted structs (#156), and #146's metadata endpoint passes the Option through so no surface reports 0.0 as a rating. vote_count is untouched.
This commit is contained in:
@@ -46,7 +46,9 @@ pub struct MovieMetadata {
|
||||
pub status: String,
|
||||
pub poster_path: Option<String>,
|
||||
pub backdrop_path: Option<String>,
|
||||
pub vote_average: f64,
|
||||
/// TMDB's rating when votes exist; an unrated title is `null`, never `0.0`
|
||||
/// (#156).
|
||||
pub vote_average: Option<f64>,
|
||||
pub vote_count: u32,
|
||||
pub homepage: Option<String>,
|
||||
/// §9.6 links out to `IMDb` for movies.
|
||||
@@ -68,7 +70,9 @@ pub struct SeriesMetadata {
|
||||
pub status: String,
|
||||
pub poster_path: Option<String>,
|
||||
pub backdrop_path: Option<String>,
|
||||
pub vote_average: f64,
|
||||
/// TMDB's rating when votes exist; an unrated title is `null`, never `0.0`
|
||||
/// (#156).
|
||||
pub vote_average: Option<f64>,
|
||||
pub vote_count: u32,
|
||||
pub homepage: Option<String>,
|
||||
/// §9.6 links out to TVDB for series.
|
||||
@@ -366,7 +370,7 @@ mod tests {
|
||||
"genres": [{"id": 18, "name": "Drama"}],
|
||||
"backdrop_path": "/eMhDKZscBd07OLpAeeAyu3N3U8c.jpg",
|
||||
"poster_path": "/uKvVjHNqB5VmOrdxqAt2F7J78ED.jpg",
|
||||
"vote_average": 8.5,
|
||||
"vote_average": 0.0,
|
||||
"vote_count": 2_911,
|
||||
"homepage": "",
|
||||
"status": "Returning Series",
|
||||
@@ -397,6 +401,11 @@ mod tests {
|
||||
|
||||
assert_eq!(body["tmdb_id"], 82_728);
|
||||
assert_eq!(body["tvdb_id"], 392_256);
|
||||
// TMDB reports vote_average: 0 for an unrated title (#156): it leaves
|
||||
// as null, never as a rating of zero. The movie case covers the rated
|
||||
// pass-through.
|
||||
assert_eq!(body["vote_average"], serde_json::Value::Null);
|
||||
assert_eq!(body["vote_count"], 2_911);
|
||||
// TMDB sends a list of episode lengths; the API reports one runtime.
|
||||
assert_eq!(body["runtime"], 55);
|
||||
assert_eq!(body["status"], "Returning Series");
|
||||
|
||||
Reference in New Issue
Block a user