Skip to content

Commit

Permalink
feat(movie): secondary sort for cast and crew by popularity
Browse files Browse the repository at this point in the history
Primary sort is still number of movies they appear in
  • Loading branch information
believer committed Jan 27, 2025
1 parent c882544 commit 18cdbea
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions db/queries.sql
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@
-- name: cast-by-id
SELECT
INITCAP(mp.job::text) AS job,
ARRAY_AGG(p.name ORDER BY num_movies DESC) AS people_names,
ARRAY_AGG(p.id ORDER BY num_movies DESC) AS people_ids,
ARRAY_AGG(p.name ORDER BY num_movies DESC, p.popularity DESC) AS people_names,
ARRAY_AGG(p.id ORDER BY num_movies DESC, p.popularity DESC) AS people_ids,
CASE mp.job
WHEN 'cast' THEN
ARRAY_AGG(COALESCE(mp.character, '')
ORDER BY num_movies DESC)
ORDER BY num_movies DESC, p.popularity DESC)
ELSE
ARRAY[]::text[]
END AS characters
Expand Down

0 comments on commit 18cdbea

Please # to comment.