Commit 6f1e7414 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FEAT] post list now set new list as list (and remove previous one).

parent 3d9e9804
......@@ -39,6 +39,8 @@ module Gargantext.API.Ngrams
, TableNgramsApiPost
, getTableNgrams
, setListNgrams
, rmListNgrams
, putListNgrams
, putListNgrams'
, tableNgramsPost
......@@ -116,7 +118,7 @@ import Data.Map.Strict (Map)
import qualified Data.Set as Set
import Control.Category ((>>>))
import Control.Concurrent
import Control.Lens (makeLenses, makePrisms, Getter, Iso', iso, from, (.~), (?=), (#), to, folded, {-withIndex, ifolded,-} view, use, (^.), (^..), (^?), (+~), (%~), (%=), sumOf, at, _Just, Each(..), itraverse_, both, forOf_, (%%~), (?~), mapped)
import Control.Lens (makeLenses, makePrisms, Getter, Iso', iso, from, (.~), (?=), (#), to, folded, {-withIndex, ifolded,-} view, use, (^.), (^..), (^?), (+~), (%~), (.~), (%=), sumOf, at, _Just, Each(..), itraverse_, both, forOf_, (%%~), (?~), mapped)
import Control.Monad.Error.Class (MonadError)
import Control.Monad.Reader
import Control.Monad.State
......@@ -673,7 +675,7 @@ instance Arbitrary a => Arbitrary (Versioned a) where
{-
-- TODO sequencs of modifications (Patchs)
-- TODO sequences of modifications (Patchs)
type NgramsIdPatch = Patch NgramsId NgramsPatch
ngramsPatch :: Int -> NgramsPatch
......@@ -854,6 +856,30 @@ addListNgrams listId ngramsType nes = do
m = Map.fromList $ (\n -> (n ^. ne_ngrams, n)) <$> nes
-}
rmListNgrams :: RepoCmdM env err m
=> ListId
-> NgramsType
-> m ()
rmListNgrams l nt = setListNgrams l nt mempty
setListNgrams :: RepoCmdM env err m
=> NodeId
-> NgramsType
-> Map NgramsTerm NgramsRepoElement
-> m ()
setListNgrams listId ngramsType ns = do
var <- view repoVar
liftIO $ modifyMVar_ var $
pure . ( r_state
. at ngramsType %~
(Just .
(at listId .~ ( Just ns))
. something
)
)
saveRepo
-- If the given list of ngrams elements contains ngrams already in
-- the repo, they will be ignored.
putListNgrams :: RepoCmdM env err m
......
......@@ -95,7 +95,7 @@ post :: FlowCmdM env err m
-> m Bool
post l m = do
-- TODO check with Version for optim
_ <- mapM (\(nt, Versioned _v ns) -> putListNgrams' l nt ns) $ toList m
_ <- mapM (\(nt, Versioned _v ns) -> setListNgrams l nt ns) $ toList m
-- TODO reindex
pure True
......
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