Commit aebaa330 authored by Nicolas Pouillard's avatar Nicolas Pouillard Committed by Alexandre Delanoë

NgramsPatches: overall structure, missing many instances

parent cfbbf557
......@@ -165,6 +165,7 @@ library:
- transformers-base
- unordered-containers
- uuid
- validity
- vector
- wai
- wai-cors
......
This diff is collapsed.
......@@ -46,7 +46,7 @@ import Data.Time (UTCTime)
import GHC.Generics (Generic)
import Servant
import Gargantext.API.Ngrams (TabType(..), TableNgramsApi, TableNgramsApiGet, tableNgramsPatch, getTableNgrams)
import Gargantext.API.Ngrams (TabType(..), TableNgramsApi, TableNgramsApiGet, tableNgramsPatch, getTableNgrams, HasRepoVar(..))
import Gargantext.Prelude
import Gargantext.Database.Types.Node
import Gargantext.Database.Utils -- (Cmd, CmdM)
......@@ -72,7 +72,8 @@ import Gargantext.Database.Types.Node (CorpusId, ContactId)
import Test.QuickCheck (elements)
import Test.QuickCheck.Arbitrary (Arbitrary, arbitrary)
type GargServer api = forall env m. CmdM env ServantErr m => ServerT api m
type GargServer api = forall env m. (CmdM env ServantErr m, HasRepoVar env)
=> ServerT api m
-------------------------------------------------------------------
-- TODO-ACCESS: access by admin only.
......
......@@ -45,10 +45,12 @@ import Web.HttpApiData (parseUrlPiece)
import qualified Jose.Jwk as Jose
import qualified Jose.Jwa as Jose
import Control.Concurrent
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.Orchestrator.Types
type PortNumber = Int
......@@ -128,6 +130,7 @@ data Env = Env
{ _env_settings :: !Settings
, _env_logger :: !LoggerSet
, _env_conn :: !Connection
, _env_repo_var :: !(MVar NgramsRepo)
, _env_manager :: !Manager
, _env_self_url :: !BaseUrl
, _env_scrapers :: !ScrapersEnv
......@@ -139,6 +142,9 @@ makeLenses ''Env
instance HasConnection Env where
connection = env_conn
instance HasRepoVar Env where
repoVar = env_repo_var
data MockEnv = MockEnv
{ _menv_firewall :: !FireWall
}
......@@ -155,12 +161,14 @@ newEnv port file = do
self_url <- parseBaseUrl $ "http://0.0.0.0:" <> show port
param <- databaseParameters file
conn <- connect param
repo_var <- newMVar initRepo
scrapers_env <- newJobEnv defaultSettings manager
logger <- newStderrLoggerSet defaultBufSize
pure $ Env
{ _env_settings = settings
, _env_logger = logger
, _env_conn = conn
, _env_repo_var = repo_var
, _env_manager = manager
, _env_scrapers = scrapers_env
, _env_self_url = self_url
......
......@@ -68,7 +68,7 @@ runCmd :: Connection -> Cmd err a -> IO (Either err a)
runCmd conn m = runExceptT $ runReaderT m conn
-- Use only for dev
runCmdDevWith :: FilePath -> Cmd ServantErr a -> IO a
runCmdDevWith :: Show err => FilePath -> Cmd err a -> IO a
runCmdDevWith fp f = do
conn <- connectGargandb fp
either (fail . show) pure =<< runCmd conn f
......
......@@ -34,4 +34,4 @@ extra-deps:
- servant-flatten-0.2
- servant-multipart-0.11.2
- stemmer-0.5.2
- validity-0.8.0.0 # patches-{map,class}
- validity-0.9.0.0 # patches-{map,class}
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