diff options
author | Profpatsch <mail@profpatsch.de> | 2024-05-15T12·09+0200 |
---|---|---|
committer | clbot <clbot@tvl.fyi> | 2024-06-03T14·55+0000 |
commit | b54ad3e5806b60096c40830d08bd6a813703e74e (patch) | |
tree | 512911db1c96053467b381ec80f1a75cf6a05095 /users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs | |
parent | a3a03a5a80209245867704a3b5425d4ae55f7458 (diff) |
feat(users/Profpatsch/whatcd-resolver): add artist albums r/8200
Simple artist album page that only shows albums the artist was involved with. Change-Id: Icff34afc6d1b39b6fb17765c1b3ea500dd4b4d95 Reviewed-on: https://cl.tvl.fyi/c/depot/+/11675 Tested-by: BuildkiteCI Autosubmit: Profpatsch <mail@profpatsch.de> Reviewed-by: Profpatsch <mail@profpatsch.de>
Diffstat (limited to 'users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs')
-rw-r--r-- | users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs | 31 |
1 files changed, 24 insertions, 7 deletions
diff --git a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs index 0a8d7dcebb1f..fe6a36bacaf9 100644 --- a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs +++ b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs @@ -213,7 +213,7 @@ htmlUi = do htmlWithQueryArgs ( label @"dbId" - <$> (singleQueryArgument "db_id" Field.utf8) + <$> (singleQueryArgument "db_id" (Field.utf8 >>> Field.decimalNatural)) ) $ \qry _span -> do artistPage qry @@ -256,7 +256,7 @@ htmlUi = do -- "https://musicbrainz.org/work/92000fd4-d304-406d-aeb4-6bdbeed318ec" -- ) -- <&> renderJsonld - bestTorrentsTable <- getBestTorrentsTable + bestTorrentsTable <- getBestTorrentsTable Nothing -- transmissionTorrentsTable <- lift @Transaction getTransmissionTorrentsTable pure $ Html.docTypeHtml @@ -305,11 +305,23 @@ htmlUi = do </body> |] -artistPage :: (HasField "dbId" dat Text, Applicative m) => dat -> m Html -artistPage dat = do +artistPage :: + ( HasField "dbId" dat Natural, + MonadPostgres m, + MonadOtel m, + MonadLogger m, + MonadThrow m, + MonadTransmission m + ) => + dat -> + m Html +artistPage dat = runTransaction $ do + torrents <- getBestTorrentsTable (Just $ label @"artistId" dat.dbId) pure [hsx| Artist ID: {dat.dbId} + + {torrents} |] type Handlers m = HandlerResponses m -> Map Text (m ResponseReceived) @@ -451,7 +463,11 @@ snipsRedactedSearch dat = do ] runTransaction $ do t - getBestTorrentsTable + getBestTorrentsTable (Nothing :: Maybe (Label "artistId" Natural)) + +data ArtistFilter = ArtistFilter + { onlyArtist :: Maybe (Label "artistId" Text) + } getBestTorrentsTable :: ( MonadTransmission m, @@ -460,9 +476,10 @@ getBestTorrentsTable :: MonadPostgres m, MonadOtel m ) => + Maybe (Label "artistId" Natural) -> Transaction m Html -getBestTorrentsTable = do - bestStale :: [TorrentData ()] <- getBestTorrents (label @"onlyDownloaded" False) +getBestTorrentsTable artistFilter = do + bestStale :: [TorrentData ()] <- getBestTorrents GetBestTorrentsFilter {onlyArtist = artistFilter, onlyDownloaded = False} actual <- getAndUpdateTransmissionTorrentsStatus ( bestStale |