From ad108e51091e19bd1645e87ec490e678467a9dc2 Mon Sep 17 00:00:00 2001 From: Profpatsch Date: Fri, 7 Jun 2024 13:58:52 +0200 Subject: [PATCH] feat(users/Profpatsch/whatcd-resolver): add to artist page Change-Id: I49c4f657b099de806cc310bbf0a17ceba09b4d0f Reviewed-on: https://cl.tvl.fyi/c/depot/+/11760 Reviewed-by: Profpatsch <mail@profpatsch.de> Autosubmit: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI --- .../whatcd-resolver/src/WhatcdResolver.hs | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs index b39f3ccfe..73a9dccb1 100644 --- a/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs +++ b/users/Profpatsch/whatcd-resolver/src/WhatcdResolver.hs @@ -262,6 +262,7 @@ htmlUi = do -- transmissionTorrentsTable <- lift @Transaction getTransmissionTorrentsTable pure $ htmlPageChrome + "whatcd-resolver" [hsx| <form hx-post="/snips/redacted/search" @@ -290,13 +291,13 @@ htmlUi = do /> |] -htmlPageChrome :: (ToHtml a) => a -> Html -htmlPageChrome body = +htmlPageChrome :: (ToHtml a) => Text -> a -> Html +htmlPageChrome title body = Html.docTypeHtml $ [hsx| <head> <!-- TODO: set nice page title for each page --> - <title>whatcd-resolver + {title} @@ -326,9 +327,15 @@ artistPage :: dat -> m Html artistPage dat = runTransaction $ do - torrents <- getBestTorrentsTable (Just $ getLabel @"artistRedactedId" dat) + fresh <- getBestTorrentsData (Just $ getLabel @"artistRedactedId" dat) + let artistName = fresh & findMaybe (\t -> t.artists & findMaybe (\a -> if a.artistId == (dat.artistRedactedId & fromIntegral @Natural @Int) then Just a.artistName else Nothing)) + let torrents = mkBestTorrentsTable fresh pure $ htmlPageChrome + ( case artistName of + Nothing -> "whatcd-resolver" + Just a -> [fmt|{a} - Artist Page - whatcd-resolver|] + ) [hsx| Artist ID: {dat.artistRedactedId}