[NGRAMS-TABLE] Add tableNgramsPost

parent 2584e64c
...@@ -772,6 +772,8 @@ addListNgrams listId ngramsType nes = do ...@@ -772,6 +772,8 @@ addListNgrams listId ngramsType nes = do
m = Map.fromList $ (\n -> (n ^. ne_ngrams, n)) <$> nes m = Map.fromList $ (\n -> (n ^. ne_ngrams, n)) <$> nes
-} -}
-- If the given list of ngrams elements contains ngrams already in
-- the repo, they will overwrite the old ones.
putListNgrams :: RepoCmdM env err m putListNgrams :: RepoCmdM env err m
=> NodeId -> NgramsType => NodeId -> NgramsType
-> [NgramsElement] -> m () -> [NgramsElement] -> m ()
...@@ -785,6 +787,8 @@ putListNgrams listId ngramsType nes = do ...@@ -785,6 +787,8 @@ putListNgrams listId ngramsType nes = do
where where
m = Map.fromList $ (\n -> (n ^. ne_ngrams, ngramsElementToRepo n)) <$> nes m = Map.fromList $ (\n -> (n ^. ne_ngrams, ngramsElementToRepo n)) <$> nes
tableNgramsPost tabType listId = putListNgrams listId tabType
-- 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
-- client. -- client.
tableNgramsPut :: (HasInvalidError err, RepoCmdM env err m) tableNgramsPut :: (HasInvalidError err, RepoCmdM env err m)
...@@ -939,6 +943,11 @@ type TableNgramsApiPut = Summary " Table Ngrams API Change" ...@@ -939,6 +943,11 @@ type TableNgramsApiPut = Summary " Table Ngrams API Change"
:> ReqBody '[JSON] (Versioned NgramsTablePatch) :> ReqBody '[JSON] (Versioned NgramsTablePatch)
:> Put '[JSON] (Versioned NgramsTablePatch) :> Put '[JSON] (Versioned NgramsTablePatch)
type TableNgramsApiPost = Summary " Table Ngrams API Adds new ngrams"
:> QueryParamR "ngramsType" TabType
:> QueryParamR "list" ListId
:> ReqBody '[JSON] [NgramsElement]
:> Post '[JSON] ()
getTableNgramsCorpus :: (RepoCmdM env err m, HasNodeError err, HasConnection env) getTableNgramsCorpus :: (RepoCmdM env err m, HasNodeError err, HasConnection env)
=> NodeId -> TabType => NodeId -> TabType
...@@ -986,12 +995,12 @@ apiNgramsTableDoc :: (RepoCmdM env err m, HasNodeError err, HasConnection env) ...@@ -986,12 +995,12 @@ apiNgramsTableDoc :: (RepoCmdM env err m, HasNodeError err, HasConnection env)
{- TODO {- TODO
--apiDocNgramsTable :: ApiDocNgramsTable --apiDocNgramsTable :: ApiDocNgramsTable
--apiDocNgramsTable :: ApiDocNgramsTable --apiDocNgramsTable :: ApiDocNgramsTable
--apiDocNgramsTable = getTableNgramsDoc -}
apiDocNgramsTable = getTableNgramsDoc
:<|> tableNgramsPut :<|> tableNgramsPut
:<|> tableNgramsPost :<|> tableNgramsPost
-- > add new ngrams to the repo (TODO NP) -- > add new ngrams to the repo (TODO NP)
-- > add new ngrams in database (TODO AD) -- > add new ngrams in database (TODO AD)
-- > index all the corpus accordingly (TODO AD) -- > index all the corpus accordingly (TODO AD)
--} -- apiNgramsTableDoc = getTableNgramsDoc
apiNgramsTableDoc = getTableNgramsDoc
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