feat(users/Profpatsch/whatcd-resolver): add artist albums

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>
This commit is contained in:
Profpatsch 2024-05-15 14:09:11 +02:00 committed by clbot
parent a3a03a5a80
commit b54ad3e580
3 changed files with 67 additions and 18 deletions

View file

@ -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