feat(db): store poster, backdrop and rating on titles
§9.6 keeps rich detail out of the database except for the three fields pure-SQL views need. Adds poster_path, backdrop_path and vote_average to movies and series, written by the daily metadata refresh in both lanes and filled at add time from the TMDB response the create flows already fetch.
This commit is contained in:
@@ -41,7 +41,9 @@ impl MovieSearchResult {
|
||||
}
|
||||
|
||||
/// A movie as TMDB describes it, reduced to what this project uses.
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
///
|
||||
/// `vote_average` is the one float, so this is `PartialEq` only.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Movie {
|
||||
/// TMDB's own id.
|
||||
pub tmdb_id: u32,
|
||||
@@ -77,6 +79,11 @@ pub struct Movie {
|
||||
pub overview: Option<String>,
|
||||
/// Path fragment, not a URL.
|
||||
pub poster_path: Option<String>,
|
||||
/// Path fragment, not a URL. §9.6 stores this on the row alongside
|
||||
/// [`Movie::poster_path`] and `vote_average`.
|
||||
pub backdrop_path: Option<String>,
|
||||
/// TMDB's rating, out of 10. Stored with the artwork (§9.6).
|
||||
pub vote_average: f64,
|
||||
}
|
||||
|
||||
impl Movie {
|
||||
@@ -114,7 +121,9 @@ impl SeriesSearchResult {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
/// TMDB's slice for series. `vote_average` is the one float, so this is
|
||||
/// `PartialEq` only.
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub struct Series {
|
||||
pub tmdb_id: u32,
|
||||
pub tvdb_id: Option<u32>,
|
||||
@@ -124,6 +133,11 @@ pub struct Series {
|
||||
pub status: String,
|
||||
pub overview: Option<String>,
|
||||
pub poster_path: Option<String>,
|
||||
/// §9.6 stores this on the row alongside `poster_path` and
|
||||
/// [`Series::vote_average`].
|
||||
pub backdrop_path: Option<String>,
|
||||
/// TMDB's rating, out of 10. Stored with the artwork (§9.6).
|
||||
pub vote_average: f64,
|
||||
pub seasons: Vec<SeasonSummary>,
|
||||
}
|
||||
|
||||
@@ -318,6 +332,10 @@ pub(crate) struct RawSeries {
|
||||
#[serde(default)]
|
||||
poster_path: Option<String>,
|
||||
#[serde(default)]
|
||||
backdrop_path: Option<String>,
|
||||
#[serde(default)]
|
||||
vote_average: f64,
|
||||
#[serde(default)]
|
||||
seasons: Vec<RawSeasonSummary>,
|
||||
#[serde(default)]
|
||||
external_ids: Option<RawExternalIds>,
|
||||
@@ -353,6 +371,8 @@ impl From<RawSeries> for Series {
|
||||
status: raw.status,
|
||||
overview: non_empty(raw.overview),
|
||||
poster_path: non_empty(raw.poster_path),
|
||||
backdrop_path: non_empty(raw.backdrop_path),
|
||||
vote_average: raw.vote_average,
|
||||
seasons: raw
|
||||
.seasons
|
||||
.into_iter()
|
||||
@@ -478,6 +498,10 @@ pub(crate) struct RawMovie {
|
||||
#[serde(default)]
|
||||
poster_path: Option<String>,
|
||||
#[serde(default)]
|
||||
backdrop_path: Option<String>,
|
||||
#[serde(default)]
|
||||
vote_average: f64,
|
||||
#[serde(default)]
|
||||
release_dates: Option<RawReleaseDates>,
|
||||
}
|
||||
|
||||
@@ -537,6 +561,8 @@ impl From<RawMovie> for Movie {
|
||||
status: raw.status,
|
||||
overview: non_empty(raw.overview),
|
||||
poster_path: non_empty(raw.poster_path),
|
||||
backdrop_path: non_empty(raw.backdrop_path),
|
||||
vote_average: raw.vote_average,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user