Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

index: change the groups to optional for migration purpose #1105

Merged
merged 1 commit into from
Jan 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 [email protected] {..} = 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
Loading