Fetch the show title while fetching an episode
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
e41c9bfdfa
commit
f8db5e1211
@ -25,8 +25,12 @@ const (
|
|||||||
FROM episodes WHERE show_imdb_id=$1;`
|
FROM episodes WHERE show_imdb_id=$1;`
|
||||||
|
|
||||||
getEpisodeQuery = `
|
getEpisodeQuery = `
|
||||||
SELECT *
|
SELECT s.title show_title, e.*
|
||||||
FROM episodes WHERE show_imdb_id=$1 AND season=$2 AND episode=$3;`
|
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
|
// episodeDB represents the Episode in the DB
|
||||||
@ -36,6 +40,7 @@ type episodeDB struct {
|
|||||||
ImdbID string `db:"imdb_id"`
|
ImdbID string `db:"imdb_id"`
|
||||||
ShowImdbID string `db:"show_imdb_id"`
|
ShowImdbID string `db:"show_imdb_id"`
|
||||||
ShowTvdbID int `db:"show_tvdb_id"`
|
ShowTvdbID int `db:"show_tvdb_id"`
|
||||||
|
ShowTitle string `db:"show_title"`
|
||||||
Season int `db:"season"`
|
Season int `db:"season"`
|
||||||
Episode int `db:"episode"`
|
Episode int `db:"episode"`
|
||||||
Title string `db:"title"`
|
Title string `db:"title"`
|
||||||
@ -70,6 +75,7 @@ func FillEpisodeFromDB(eDB *episodeDB, pEpisode *polochon.ShowEpisode) {
|
|||||||
// Keep the data that never changes but only if we have it
|
// Keep the data that never changes but only if we have it
|
||||||
updateIfNonEmpty(&pEpisode.EpisodeImdbID, eDB.ImdbID)
|
updateIfNonEmpty(&pEpisode.EpisodeImdbID, eDB.ImdbID)
|
||||||
updateIfNonEmpty(&pEpisode.ShowImdbID, eDB.ShowImdbID)
|
updateIfNonEmpty(&pEpisode.ShowImdbID, eDB.ShowImdbID)
|
||||||
|
updateIfNonEmpty(&pEpisode.ShowTitle, eDB.ShowTitle)
|
||||||
updateIfNonZeroInt(&pEpisode.TvdbID, eDB.TvdbID)
|
updateIfNonZeroInt(&pEpisode.TvdbID, eDB.TvdbID)
|
||||||
updateIfNonZeroInt(&pEpisode.ShowTvdbID, eDB.ShowTvdbID)
|
updateIfNonZeroInt(&pEpisode.ShowTvdbID, eDB.ShowTvdbID)
|
||||||
pEpisode.Season = eDB.Season
|
pEpisode.Season = eDB.Season
|
||||||
|
Loading…
x
Reference in New Issue
Block a user