Skip to content

Commit

Permalink
Merge pull request #1105 from TristanCacqueray/optional-mapping
Browse files Browse the repository at this point in the history
index: change the groups to optional for migration purpose
  • Loading branch information
mergify[bot] authored Jan 9, 2024
2 parents 79a703a + 79ce567 commit 8cab192
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/Monocle/Backend/Documents.hs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ import Monocle.Protob.Search qualified as SearchPB
data Author = Author
{ authorMuid :: LText
, authorUid :: LText
, authorGroups :: [LText]
, authorGroups :: Maybe [LText]
}
deriving (Show, Eq, Generic)

Expand All @@ -51,7 +51,7 @@ instance From ChangePB.Ident Author where
Author
{ authorMuid = identMuid
, authorUid = identUid
, authorGroups = toList identGroups
, authorGroups = Just $ toList identGroups
}

fromMaybeIdent :: Maybe ChangePB.Ident -> Author
Expand Down
2 changes: 1 addition & 1 deletion src/Monocle/Backend/Index.hs
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,7 @@ toAuthor (Just ChangePB.Ident {..}) =
Monocle.Backend.Documents.Author
{ authorMuid = identMuid
, authorUid = identUid
, authorGroups = toList identGroups
, authorGroups = Just $ toList identGroups
}
toAuthor Nothing =
Monocle.Backend.Documents.Author
Expand Down
2 changes: 1 addition & 1 deletion src/Monocle/Backend/Janitor.hs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import Streaming.Prelude qualified as Streaming

updateAuthor :: Config.Index -> D.Author -> D.Author
updateAuthor index author@D.Author {..} = case getIdent of
Just (identMuid, identGroups) -> D.Author (from identMuid) authorUid (from <$> identGroups)
Just (identMuid, identGroups) -> D.Author (from identMuid) authorUid (Just $ from <$> identGroups)
Nothing
| newMuid /= from authorMuid -> D.Author (from newMuid) authorUid authorGroups
| otherwise -> author
Expand Down
6 changes: 3 additions & 3 deletions src/Monocle/Backend/Test.hs
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ testIndexChanges = withTenant doTest
, echangeTitle = title
, echangeRepositoryFullname = "fakerepo"
, echangeUrl = "https://fakehost/change/" <> show number
, echangeAuthor = Author "John" "John" ["dev", "core"]
, echangeAuthor = Author "John" "John" (Just ["dev", "core"])
}

testIndexEvents :: Assertion
Expand Down Expand Up @@ -609,7 +609,7 @@ testJanitorUpdateIdents = do
, idents = Just [Config.Ident ["github.com/john"] (Just ["dev", "core"]) "John Doe"]
, search_aliases = Nothing
}
expectedAuthor = Author "John Doe" "github.com/john" ["dev", "core"]
expectedAuthor = Author "John Doe" "github.com/john" (Just ["dev", "core"])

doUpdateIndentOnEventsTest :: Eff [MonoQuery, ElasticEffect, LoggerEffect, IOE] ()
doUpdateIndentOnEventsTest = E.runFailIO $ dieOnEsError do
Expand All @@ -623,7 +623,7 @@ testJanitorUpdateIdents = do
evt2' <- I.getChangeEventById $ I.getEventDocId evt2
assertEqual' "Ensure event not changed" evt2' $ Just evt2
where
evt1 = mkEventWithAuthor "e1" (Author "john" "github.com/john" ["not-core"])
evt1 = mkEventWithAuthor "e1" (Author "john" "github.com/john" (Just ["not-core"]))
evt2 = mkEventWithAuthor "e2" (Author "paul" "github.com/paul" mempty)
mkEventWithAuthor ::
-- eventId
Expand Down

0 comments on commit 8cab192

Please sign in to comment.