[NGRAMS-REPO] Mock repo in dev-mode

parent 3a4ebb3e
......@@ -176,9 +176,8 @@ toNgramsElement ns = map toNgramsElement' ns
$ map (\(NgramsTableData _ p t _ _ _) -> (p, Set.singleton t)) ns
-}
instance Arbitrary NgramsTable where
arbitrary = elements
[ NgramsTable
mockTable :: NgramsTable
mockTable = NgramsTable
[ NgramsElement "animal" GraphList 1 Nothing (mSetFromList ["dog", "cat"])
, NgramsElement "cat" GraphList 1 (Just "animal") mempty
, NgramsElement "cats" StopList 4 Nothing mempty
......@@ -192,7 +191,10 @@ instance Arbitrary NgramsTable where
, NgramsElement "moon" CandidateList 1 Nothing mempty
, NgramsElement "sky" StopList 1 Nothing mempty
]
]
instance Arbitrary NgramsTable where
arbitrary = pure mockTable
instance ToSchema NgramsTable
------------------------------------------------------------------------
......@@ -547,6 +549,14 @@ type NgramsState = Map ListId (Map NgramsType NgramsTableMap)
type NgramsStatePatch = PatchMap ListId (PatchMap NgramsType NgramsTablePatch)
type NgramsRepo = Repo NgramsState NgramsStatePatch
initMockRepo :: NgramsRepo
initMockRepo = Repo 1 s []
where
s = Map.singleton 1
$ Map.singleton Ngrams.NgramsTerms
$ Map.fromList
[ (n ^. ne_ngrams, n) | n <- mockTable ^. _NgramsTable ]
class HasRepoVar env where
repoVar :: Getter env (MVar NgramsRepo)
......
......@@ -50,7 +50,7 @@ import Control.Monad.Logger
import Control.Lens
import Gargantext.Prelude
import Gargantext.Database.Utils (databaseParameters, HasConnection(..))
import Gargantext.API.Ngrams (NgramsRepo, HasRepoVar(..), initRepo)
import Gargantext.API.Ngrams (NgramsRepo, HasRepoVar(..), initMockRepo)
import Gargantext.API.Orchestrator.Types
type PortNumber = Int
......@@ -161,7 +161,7 @@ newEnv port file = do
self_url <- parseBaseUrl $ "http://0.0.0.0:" <> show port
param <- databaseParameters file
conn <- connect param
repo_var <- newMVar initRepo
repo_var <- newMVar initMockRepo
scrapers_env <- newJobEnv defaultSettings manager
logger <- newStderrLoggerSet defaultBufSize
pure $ Env
......
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