Skip to content

Commit

Permalink
Add warning logs to migration script
Browse files Browse the repository at this point in the history
  • Loading branch information
smatting committed Nov 23, 2022
1 parent 15d6584 commit 2c1c036
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions services/galley/migrate-data/src/V2_MigrateMLSMembers.hs
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,26 @@ getMemberClientsFromLegacy = paginateC cql (paramsP LocalQuorum () pageSize) x5
cql :: PrepQuery R () (ConvId, Domain, UserId, ClientId, KeyPackageRef)
cql = "SELECT conv, user_domain, user, client, key_package_ref from member_client"

lookupGroupIds :: (MonadUnliftIO m, MonadClient m) => [ConvId] -> m (Map ConvId GroupId)
lookupGroupIds :: [ConvId] -> MigrationActionT IO (Map ConvId GroupId)
lookupGroupIds convIds = do
rows <- pooledMapConcurrentlyN 8 (\convId -> retry x5 (query1 cql (params LocalQuorum (Identity convId)))) convIds
rows
rows' <-
rows
& mapM
( \case
(Just (c, mg)) -> do
case mg of
Nothing -> do
Log.warn (Log.msg ("No group found for conv " <> show c))
pure Nothing
Just g -> pure (Just (c, g))
Nothing -> do
Log.warn (Log.msg ("Conversation is missing for entry" :: Text))
pure Nothing
)

rows'
& catMaybes
& mapMaybe (\(c, mg) -> (c,) <$> mg)
& Map.fromList
& pure
where
Expand Down

0 comments on commit 2c1c036

Please sign in to comment.