Fix the NgramsPatch type

parent 854cc11f
Pipeline #101 canceled with stage
...@@ -163,6 +163,7 @@ instance ToSchema a => ToSchema (PatchSet a) ...@@ -163,6 +163,7 @@ instance ToSchema a => ToSchema (PatchSet a)
instance ToSchema a => ToSchema (Replace a) where instance ToSchema a => ToSchema (Replace a) where
declareNamedSchema (_ :: proxy (Replace a)) = do declareNamedSchema (_ :: proxy (Replace a)) = do
-- TODO Keep constructor is not supported here.
aSchema <- declareSchemaRef (Proxy :: Proxy a) aSchema <- declareSchemaRef (Proxy :: Proxy a)
return $ NamedSchema (Just "Replace") $ mempty return $ NamedSchema (Just "Replace") $ mempty
& type_ .~ SwaggerObject & type_ .~ SwaggerObject
...@@ -174,7 +175,7 @@ instance ToSchema a => ToSchema (Replace a) where ...@@ -174,7 +175,7 @@ instance ToSchema a => ToSchema (Replace a) where
& required .~ [ "old", "new" ] & required .~ [ "old", "new" ]
data NgramsPatch = data NgramsPatch =
NgramsPatch { _patch_children :: PatchSet NgramsElement NgramsPatch { _patch_children :: PatchSet NgramsTerm
, _patch_list :: Replace ListType -- TODO Map UserId ListType , _patch_list :: Replace ListType -- TODO Map UserId ListType
} }
deriving (Ord, Eq, Show, Generic) deriving (Ord, Eq, Show, Generic)
...@@ -275,13 +276,13 @@ mkListsUpdate lId patches = ...@@ -275,13 +276,13 @@ mkListsUpdate lId patches =
] ]
mkChildrenGroups :: ListId mkChildrenGroups :: ListId
-> (PatchSet NgramsElement -> Set NgramsElement) -> (PatchSet NgramsTerm -> Set NgramsTerm)
-> NgramsTablePatch -> NgramsTablePatch
-> [(ListId, NgramsParent, NgramsChild, Maybe Double)] -> [(ListId, NgramsParent, NgramsChild, Maybe Double)]
mkChildrenGroups lId addOrRem patches = mkChildrenGroups lId addOrRem patches =
[ (lId, parent, child, Just 1) [ (lId, parent, child, Just 1)
| (parent, patch) <- patches ^.. ntp_ngrams_patches . ifolded . withIndex | (parent, patch) <- patches ^.. ntp_ngrams_patches . ifolded . withIndex
, child <- patch ^.. patch_children . to addOrRem . folded . ne_ngrams , child <- patch ^.. patch_children . to addOrRem . folded
] ]
-- Apply the given patch to the DB and returns the patch to be applied on the -- Apply the given patch to the DB and returns the patch to be applied on the
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment