fix(users/Profpatsch/whatcd-resolver): refresh table on delete
Instead of serving a stale table when a torrent gets deleted, fetch the whole view again. This is a little wasteful, but torrents shouldn’t get deleted very often, so it’s fine. Change-Id: If33d517270421881852158f27dbc3e7d24880d3b Reviewed-on: https://cl.tvl.fyi/c/depot/+/12333 Reviewed-by: Profpatsch <mail@profpatsch.de> Tested-by: BuildkiteCI
This commit is contained in:
parent
f6dc1f1819
commit
f49e047588
2 changed files with 19 additions and 7 deletions
|
|
@ -61,7 +61,7 @@ getAndUpdateTransmissionTorrentsStatus ::
|
|||
HasField "torrentId" info Int
|
||||
) =>
|
||||
Map (Label "torrentHash" Text) info ->
|
||||
(Transaction m (Map (Label "torrentHash" Text) (Label "percentDone" Percentage)))
|
||||
(Transaction m (Label "knownTorrentsStale" Bool, (Map (Label "torrentHash" Text) (Label "percentDone" Percentage))))
|
||||
getAndUpdateTransmissionTorrentsStatus knownTorrents = inSpan' "getAndUpdateTransmissionTorrentsStatus" $ \span -> do
|
||||
let fields = ["hashString", "percentDone"]
|
||||
actualTorrents <-
|
||||
|
|
@ -82,7 +82,7 @@ getAndUpdateTransmissionTorrentsStatus knownTorrents = inSpan' "getAndUpdateTran
|
|||
if
|
||||
| Map.null toDelete -> do
|
||||
addEventSimple span "We know about all transmission hashes."
|
||||
pure actualTorrents
|
||||
pure (label @"knownTorrentsStale" False, actualTorrents)
|
||||
| otherwise -> inSpan' "Delete outdated transmission hashes" $ \span' -> do
|
||||
addAttribute
|
||||
span'
|
||||
|
|
@ -108,7 +108,7 @@ getAndUpdateTransmissionTorrentsStatus knownTorrents = inSpan' "getAndUpdateTran
|
|||
WHERE transmission_torrent_hash = ANY (?::text[])
|
||||
|]
|
||||
$ Only (toDelete & Map.keys <&> (.torrentHash) & PGArray :: PGArray Text)
|
||||
pure actualTorrents
|
||||
pure (label @"knownTorrentsStale" True, actualTorrents)
|
||||
|
||||
getTransmissionTorrentsTable ::
|
||||
(MonadTransmission m, MonadThrow m, MonadLogger m, MonadOtel m) => m Html
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue