feat(users/Profpatsch/whatcd-resolver): show latest releases
Let’s start improving the main page. So far, it was just all release groups sorted by weight on a single page, which was not super helpful (and got kinda large). The first feature is to show the latest releases that are known. This is done by torrent group ID. This ID does not always correspond to the date, but can also be a very old album that gets uploaded, or (seldomly) a group that gets merged for metadata. We should think about restricting this to favourites, automatically marking everything as favourite where we have an album downloaded or clicked on the artist before, and then selectively allow to un-mark it after the fact. An even stronger “not interested” could be used to automatically reclaim seedbox space once it becomes an issue. Eventually (after implementing favourites), we should introduce a job system that automatically updates these entries every few hours. Maybe even have a “very interested” feature that automatically downloads everything new for an artist? And then a “veryvery interested” feature that also buys the thing from bandcamp lol Change-Id: I467c350722279ff37150f847f5014d7e0e67e626 Reviewed-on: https://cl.tvl.fyi/c/depot/+/13225 Tested-by: BuildkiteCI Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
parent
2d522a9321
commit
b6fee0e084
2 changed files with 66 additions and 61 deletions
|
|
@ -622,9 +622,12 @@ getTorrentById dat = do
|
|||
data GetBestTorrentsFilter = GetBestTorrentsFilter
|
||||
{ onlyArtist :: Maybe (Label "artistRedactedId" Int),
|
||||
onlyTheseTorrents :: Maybe ([Label "torrentId" Int]),
|
||||
limitResults :: Maybe Natural
|
||||
limitResults :: Maybe Natural,
|
||||
ordering :: BestTorrentsOrdering
|
||||
}
|
||||
|
||||
data BestTorrentsOrdering = BySeedingWeight | ByLastReleases
|
||||
|
||||
-- | Find the best torrent for each torrent group (based on the seeding_weight)
|
||||
getBestTorrents ::
|
||||
(MonadPostgres m) =>
|
||||
|
|
@ -632,7 +635,7 @@ getBestTorrents ::
|
|||
Transaction m [TorrentData ()]
|
||||
getBestTorrents opts = do
|
||||
queryWith
|
||||
[sql|
|
||||
( [sql|
|
||||
WITH filtered_torrents AS (
|
||||
SELECT DISTINCT ON (torrent_group)
|
||||
id
|
||||
|
|
@ -669,9 +672,14 @@ getBestTorrents opts = do
|
|||
FROM filtered_torrents f
|
||||
JOIN redacted.torrents t ON t.id = f.id
|
||||
JOIN redacted.torrent_groups tg ON tg.id = t.torrent_group
|
||||
ORDER BY seeding_weight DESC
|
||||
|]
|
||||
<> case opts.ordering of
|
||||
BySeedingWeight -> [fmt|ORDER BY seeding_weight DESC|] <> "\n"
|
||||
ByLastReleases -> [fmt|ORDER BY tg.group_id DESC|] <> "\n"
|
||||
<> [sql|
|
||||
LIMIT ?::int
|
||||
|]
|
||||
)
|
||||
( do
|
||||
let (onlyArtistB, onlyArtistId) = case opts.onlyArtist of
|
||||
Nothing -> (True, 0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue