fix(users/Profpatsch/whatcd-resolver): db_id -> redacted_id

We’re using the redacted id, not the database id.
This is more stable.

Change-Id: I4d24e5bc6cc469d811cb1402a83157359576ef77
Reviewed-on: https://cl.tvl.fyi/c/depot/+/11683
Autosubmit: Profpatsch <mail@profpatsch.de>
Reviewed-by: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
This commit is contained in:
Profpatsch 2024-05-16 22:59:21 +02:00 committed by clbot
parent 54ea3eeacb
commit 94ea6fd69e
2 changed files with 10 additions and 10 deletions

View file

@ -389,7 +389,7 @@ getTorrentById dat = do
data GetBestTorrentsFilter = GetBestTorrentsFilter data GetBestTorrentsFilter = GetBestTorrentsFilter
{ onlyDownloaded :: Bool, { onlyDownloaded :: Bool,
onlyArtist :: Maybe (Label "artistId" Natural) onlyArtist :: Maybe (Label "redactedId" Natural)
} }
-- | Find the best torrent for each torrent group (based on the seeding_weight) -- | Find the best torrent for each torrent group (based on the seeding_weight)
@ -429,7 +429,7 @@ getBestTorrents opts = do
( do ( do
let (onlyArtistB, onlyArtistId) = case opts.onlyArtist of let (onlyArtistB, onlyArtistId) = case opts.onlyArtist of
Nothing -> (True, 0) Nothing -> (True, 0)
Just a -> (False, a.artistId) Just a -> (False, a.redactedId)
( opts.onlyDownloaded :: Bool, ( opts.onlyDownloaded :: Bool,
onlyArtistB :: Bool, onlyArtistB :: Bool,
onlyArtistId & fromIntegral @Natural @Int onlyArtistId & fromIntegral @Natural @Int

View file

@ -213,8 +213,8 @@ htmlUi = do
let HandlerResponses {htmlWithQueryArgs} = respond let HandlerResponses {htmlWithQueryArgs} = respond
htmlWithQueryArgs htmlWithQueryArgs
( label @"dbId" ( label @"redactedId"
<$> (singleQueryArgument "db_id" (Field.utf8 >>> Field.decimalNatural)) <$> (singleQueryArgument "redacted_id" (Field.utf8 >>> Field.decimalNatural))
) )
$ \qry _span -> do $ \qry _span -> do
artistPage qry artistPage qry
@ -315,7 +315,7 @@ htmlPageChrome body =
|] |]
artistPage :: artistPage ::
( HasField "dbId" dat Natural, ( HasField "redactedId" dat Natural,
MonadPostgres m, MonadPostgres m,
MonadOtel m, MonadOtel m,
MonadLogger m, MonadLogger m,
@ -325,11 +325,11 @@ artistPage ::
dat -> dat ->
m Html m Html
artistPage dat = runTransaction $ do artistPage dat = runTransaction $ do
torrents <- getBestTorrentsTable (Just $ label @"artistId" dat.dbId) torrents <- getBestTorrentsTable (Just $ getLabel @"redactedId" dat)
pure $ pure $
htmlPageChrome htmlPageChrome
[hsx| [hsx|
Artist ID: {dat.dbId} Artist ID: {dat.redactedId}
{torrents} {torrents}
|] |]
@ -473,7 +473,7 @@ snipsRedactedSearch dat = do
] ]
runTransaction $ do runTransaction $ do
t t
getBestTorrentsTable (Nothing :: Maybe (Label "artistId" Natural)) getBestTorrentsTable (Nothing :: Maybe (Label "redactedId" Natural))
data ArtistFilter = ArtistFilter data ArtistFilter = ArtistFilter
{ onlyArtist :: Maybe (Label "artistId" Text) { onlyArtist :: Maybe (Label "artistId" Text)
@ -486,7 +486,7 @@ getBestTorrentsTable ::
MonadPostgres m, MonadPostgres m,
MonadOtel m MonadOtel m
) => ) =>
Maybe (Label "artistId" Natural) -> Maybe (Label "redactedId" Natural) ->
Transaction m Html Transaction m Html
getBestTorrentsTable artistFilter = do getBestTorrentsTable artistFilter = do
bestStale :: [TorrentData ()] <- getBestTorrents GetBestTorrentsFilter {onlyArtist = artistFilter, onlyDownloaded = False} bestStale :: [TorrentData ()] <- getBestTorrents GetBestTorrentsFilter {onlyArtist = artistFilter, onlyDownloaded = False}
@ -527,7 +527,7 @@ getBestTorrentsTable artistFilter = do
b.artists b.artists
<&> ( \a -> <&> ( \a ->
T2 T2
(label @"url" [fmt|/artist?db_id={a.artistId}|]) (label @"url" [fmt|/artist?redacted_id={a.artistId}|])
(label @"content" $ Html.toHtml @Text a.artistName) (label @"content" $ Html.toHtml @Text a.artistName)
) )
& mkLinkList & mkLinkList