Fix queries on the views with ratings
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
The old behaviour was a simple join, if there's no rating for the movie, there's no result for movie. The backend can not return the movie and does a new GetDetails from online detailers.
This commit is contained in:
parent
d6ed40ba6a
commit
7832c407ee
19
migrations/0010_fix_rating_tables.down.sql
Normal file
19
migrations/0010_fix_rating_tables.down.sql
Normal file
@ -0,0 +1,19 @@
|
||||
CREATE OR REPLACE VIEW movies_with_rating AS
|
||||
SELECT
|
||||
m.id, m.imdb_id, m.title, m.plot, m.tmdb_id, m.year, m.original_title, m.runtime, m.sort_title, m.tagline, m.genres,
|
||||
r.rating,
|
||||
r.votes,
|
||||
m.updated_at, m.created_at
|
||||
FROM movies m
|
||||
JOIN imdb_ratings r
|
||||
ON m.imdb_id = r.imdb_id;
|
||||
|
||||
CREATE OR REPLACE VIEW shows_with_rating AS
|
||||
SELECT
|
||||
s.id, s.imdb_id, s.title, s.plot, s.tvdb_id, s.year, s.first_aired,
|
||||
r.rating,
|
||||
r.votes,
|
||||
s.updated_at, s.created_at
|
||||
FROM shows s
|
||||
JOIN imdb_ratings r
|
||||
ON s.imdb_id = r.imdb_id;
|
19
migrations/0010_fix_rating_tables.up.sql
Normal file
19
migrations/0010_fix_rating_tables.up.sql
Normal file
@ -0,0 +1,19 @@
|
||||
CREATE OR REPLACE VIEW movies_with_rating AS
|
||||
SELECT
|
||||
m.id, m.imdb_id, m.title, m.plot, m.tmdb_id, m.year, m.original_title, m.runtime, m.sort_title, m.tagline, m.genres,
|
||||
CASE WHEN r.rating IS NULL THEN m.rating ELSE r.rating END,
|
||||
CASE WHEN r.votes IS NULL THEN m.votes ELSE r.votes END,
|
||||
m.updated_at, m.created_at
|
||||
FROM movies m
|
||||
LEFT JOIN imdb_ratings r
|
||||
ON m.imdb_id = r.imdb_id;
|
||||
|
||||
CREATE OR REPLACE VIEW shows_with_rating AS
|
||||
SELECT
|
||||
s.id, s.imdb_id, s.title, s.plot, s.tvdb_id, s.year, s.first_aired,
|
||||
CASE WHEN r.rating IS NULL THEN s.rating ELSE r.rating END,
|
||||
CASE WHEN r.votes IS NULL THEN 0 ELSE r.votes END,
|
||||
s.updated_at, s.created_at
|
||||
FROM shows s
|
||||
LEFT JOIN imdb_ratings r
|
||||
ON s.imdb_id = r.imdb_id;
|
Loading…
x
Reference in New Issue
Block a user