Commit 01f6f79c authored by Nicolas Pouillard's avatar Nicolas Pouillard

G.API.Ngrams: add newNgramsFromNgramsStatePatch

parent 8013e11f
Pipeline #1236 failed with stage
...@@ -83,7 +83,7 @@ module Gargantext.API.Ngrams ...@@ -83,7 +83,7 @@ module Gargantext.API.Ngrams
where where
import Control.Concurrent import Control.Concurrent
import Control.Lens ((.~), view, (^.), (^..), (+~), (%~), (.~), sumOf, at, _Just, Each(..), (%%~), mapped) import Control.Lens ((.~), view, (^.), (^..), (+~), (%~), (.~), sumOf, at, _Just, Each(..), (%%~), mapped, ifolded, withIndex)
import Control.Monad.Reader import Control.Monad.Reader
import Data.Aeson hiding ((.=)) import Data.Aeson hiding ((.=))
import qualified Data.Aeson.Text as DAT import qualified Data.Aeson.Text as DAT
...@@ -275,6 +275,12 @@ currentVersion = do ...@@ -275,6 +275,12 @@ currentVersion = do
r <- liftBase $ readMVar var r <- liftBase $ readMVar var
pure $ r ^. r_version pure $ r ^. r_version
newNgramsFromNgramsStatePatch :: NgramsStatePatch -> [Ngrams]
newNgramsFromNgramsStatePatch p =
[ text2ngrams (unNgramsTerm n)
| (n,np) <- p ^.. _PatchMap . each . _PatchMap . each . _NgramsTablePatch . _PatchMap . ifolded . withIndex
, _ <- np ^.. patch_new . _Just
]
-- tableNgramsPut :: (HasInvalidError err, RepoCmdM env err m) -- tableNgramsPut :: (HasInvalidError err, RepoCmdM env err m)
commitStatePatch :: RepoCmdM env err m => Versioned NgramsStatePatch -> m (Versioned NgramsStatePatch) commitStatePatch :: RepoCmdM env err m => Versioned NgramsStatePatch -> m (Versioned NgramsStatePatch)
......
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