Skip to content

Commit

Permalink
Add the author's group field into the Monocle schema
Browse files Browse the repository at this point in the history
  • Loading branch information
morucci committed Nov 28, 2023
1 parent b6f17ff commit f2dcbbd
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/Monocle/Backend/Index.hs
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ instance ToJSON AuthorMapping where
object
[ "uid" .= object ["type" .= ("keyword" :: Text)]
, "muid" .= object ["type" .= ("keyword" :: Text)]
, "groups" .= object ["type" .= ("keyword" :: Text)]
]

instance ToJSON AuthorIndexMapping where
Expand Down Expand Up @@ -240,7 +241,7 @@ createIndex indexName mapping = do
retryPolicy = exponentialBackoff 500_000 <> limitRetries 7

configVersion :: ConfigVersion
configVersion = ConfigVersion 5
configVersion = ConfigVersion 6

configIndex :: BH.IndexName
configIndex = BH.IndexName "monocle.config"
Expand Down Expand Up @@ -373,13 +374,20 @@ upgradeConfigV5 = do
logInfo "Applying migration to schema V5 on workspace" ["index" .= indexName]
void $ esPutMapping indexName mergedCommitField

upgradeConfigV6 :: forall es. MonoQuery :> es => IndexEffects es => Eff es ()
upgradeConfigV6 = do
indexName <- getIndexName
logInfo "Applying migration to schema V6 on workspace" ["index" .= indexName]
void $ esPutMapping indexName ChangesIndexMapping

upgrades :: forall es. (E.Fail :> es, MonoQuery :> es) => IndexEffects es => [(ConfigVersion, Eff es ())]
upgrades =
[ (ConfigVersion 1, upgradeConfigV1)
, (ConfigVersion 2, upgradeConfigV2)
, (ConfigVersion 3, void upgradeConfigV3)
, (ConfigVersion 4, void upgradeConfigV4)
, (ConfigVersion 5, void upgradeConfigV5)
, (ConfigVersion 6, void upgradeConfigV6)
]

newtype ConfigVersion = ConfigVersion Integer
Expand Down

0 comments on commit f2dcbbd

Please sign in to comment.