Fetch the show title while fetching an episode
This commit is contained in:
parent
1a69cf8892
commit
89c6372f58
@ -26,8 +26,12 @@ const (
|
||||
FROM episodes WHERE show_imdb_id=$1;`
|
||||
|
||||
getEpisodeQuery = `
|
||||
SELECT *
|
||||
FROM episodes WHERE show_imdb_id=$1 AND season=$2 AND episode=$3;`
|
||||
SELECT s.title show_title, e.*
|
||||
FROM shows s , episodes e
|
||||
WHERE s.imdb_id = e.show_imdb_id
|
||||
AND e.show_imdb_id=$1
|
||||
AND e.season=$2
|
||||
AND e.episode=$3;`
|
||||
)
|
||||
|
||||
// episodeDB represents the Episode in the DB
|
||||
@ -37,6 +41,7 @@ type episodeDB struct {
|
||||
ImdbID string `db:"imdb_id"`
|
||||
ShowImdbID string `db:"show_imdb_id"`
|
||||
ShowTvdbID int `db:"show_tvdb_id"`
|
||||
ShowTitle string `db:"show_title"`
|
||||
Season int `db:"season"`
|
||||
Episode int `db:"episode"`
|
||||
Title string `db:"title"`
|
||||
@ -71,6 +76,7 @@ func FillEpisodeFromDB(eDB *episodeDB, pEpisode *polochon.ShowEpisode) {
|
||||
// Keep the data that never changes but only if we have it
|
||||
updateIfNonEmpty(&pEpisode.EpisodeImdbID, eDB.ImdbID)
|
||||
updateIfNonEmpty(&pEpisode.ShowImdbID, eDB.ShowImdbID)
|
||||
updateIfNonEmpty(&pEpisode.ShowTitle, eDB.ShowTitle)
|
||||
updateIfNonZeroInt(&pEpisode.TvdbID, eDB.TvdbID)
|
||||
updateIfNonZeroInt(&pEpisode.ShowTvdbID, eDB.ShowTvdbID)
|
||||
pEpisode.Season = eDB.Season
|
||||
|
Loading…
x
Reference in New Issue
Block a user