refactor(users/Profpatsch/whatcd-resolver): prepare SQL changes
For the next step, we need to put more things in WITH-Clauses, so let’s prepare it now to get a nicer diff. Change-Id: Ibd5b67c77c87ce3d6aa0ab04ca3d66f9b90dc856 Reviewed-on: https://cl.tvl.fyi/c/depot/+/13237 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
parent
2adf7b5634
commit
1e188ee116
1 changed files with 35 additions and 20 deletions
|
|
@ -653,7 +653,8 @@ getBestTorrents opts = do
|
||||||
-- prefer torrents which we already downloaded
|
-- prefer torrents which we already downloaded
|
||||||
torrent_file,
|
torrent_file,
|
||||||
seeding_weight DESC
|
seeding_weight DESC
|
||||||
)
|
),
|
||||||
|
prepare1 AS (
|
||||||
SELECT
|
SELECT
|
||||||
tg.group_id,
|
tg.group_id,
|
||||||
t.torrent_id,
|
t.torrent_id,
|
||||||
|
|
@ -673,11 +674,25 @@ getBestTorrents opts = do
|
||||||
FROM filtered_torrents f
|
FROM filtered_torrents f
|
||||||
JOIN redacted.torrents t ON t.id = f.id
|
JOIN redacted.torrents t ON t.id = f.id
|
||||||
JOIN redacted.torrent_groups tg ON tg.id = t.torrent_group
|
JOIN redacted.torrent_groups tg ON tg.id = t.torrent_group
|
||||||
WHERE tg.full_json_result->>'releaseType' <> ALL (?::text[])
|
WHERE
|
||||||
|
tg.full_json_result->>'releaseType' <> ALL (?::text[])
|
||||||
|
)
|
||||||
|
SELECT
|
||||||
|
group_id,
|
||||||
|
torrent_id,
|
||||||
|
seeding_weight,
|
||||||
|
release_type,
|
||||||
|
artists,
|
||||||
|
group_name,
|
||||||
|
group_year,
|
||||||
|
has_torrent_file,
|
||||||
|
transmission_torrent_hash,
|
||||||
|
torrent_format
|
||||||
|
FROM prepare1
|
||||||
|]
|
|]
|
||||||
<> case opts.ordering of
|
<> case opts.ordering of
|
||||||
BySeedingWeight -> [fmt|ORDER BY seeding_weight DESC|] <> "\n"
|
BySeedingWeight -> [fmt|ORDER BY seeding_weight DESC|] <> "\n"
|
||||||
ByLastReleases -> [fmt|ORDER BY tg.group_id DESC|] <> "\n"
|
ByLastReleases -> [fmt|ORDER BY group_id DESC|] <> "\n"
|
||||||
<> [sql|
|
<> [sql|
|
||||||
LIMIT ?::int
|
LIMIT ?::int
|
||||||
|]
|
|]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue