feat(users/Profpatsch/MonadPostgres): add unzipPGArray fns

Change-Id: I47ae3520998c1da7a8ad34231fd5af39240a771d
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12471
Tested-by: BuildkiteCI
Reviewed-by: Profpatsch <mail@profpatsch.de>
This commit is contained in:
Profpatsch 2024-09-13 11:26:38 +02:00
parent f49e047588
commit 9d02fc4ff1
2 changed files with 75 additions and 8 deletions

View file

@ -275,20 +275,23 @@ redactedSearchAndInsert extraArguments = do
, torrent_id
, full_json_result)
|]
( [ ( dat.torrentGroupIdPg :: Int,
group.torrentId :: Int,
group.fullJsonResult :: Json.Value
)
( [ T3
(getLabel @"torrentGroupIdPg" dat)
(getLabel @"torrentId" group)
(getLabel @"fullJsonResult" group)
| dat <- dats,
group <- dat.torrents
]
& unzip3PGArray
@"torrentGroupIdPg"
@Int
@"torrentId"
@Int
@"fullJsonResult"
@Json.Value
)
pure ()
unzip3PGArray :: [(a1, a2, a3)] -> (PGArray a1, PGArray a2, PGArray a3)
unzip3PGArray xs = xs & unzip3 & \(a, b, c) -> (PGArray a, PGArray b, PGArray c)
redactedGetTorrentFileAndInsert ::
( HasField "torrentId" r Int,
MonadPostgres m,