Commit ec9906ef authored by Alexandre Delanoë's avatar Alexandre Delanoë

[BIN] import quick arg to create new users.

parent d556ab83
......@@ -38,7 +38,7 @@ import Control.Monad.IO.Class (liftIO)
main :: IO ()
main = do
[user, iniPath, name, corpusPath] <- getArgs
[user, iniPath, name, corpusPath, users] <- getArgs
--{-
let createUsers :: Cmd ServantErr Int64
......@@ -49,7 +49,7 @@ main = do
--}
let cmdCorpus :: forall m. FlowCmdM DevEnv ServantErr m => m [CorpusId]
cmdCorpus = do
docs <- liftIO (splitEvery 3000 <$> readFile corpusPath :: IO [[GrandDebatReference ]])
docs <- liftIO (splitEvery 500 <$> readFile corpusPath :: IO [[GrandDebatReference ]])
ids <- flowCorpus'' (Text.pack user) (Text.pack name) (Mono FR) docs
pure ids
......@@ -57,7 +57,9 @@ main = do
env <- newDevEnvWith iniPath
-- Better if we keep only one call to runCmdDev.
_ <- runCmdDev env createUsers
_ <- if users == "0"
then runCmdDev env createUsers
else pure 1
_ <- runCmdDev env cmdCorpus
pure ()
......
......@@ -104,7 +104,7 @@ flowCorpusSearchInDatabase u q = do
-- TODO uniformize language of corpus
flowCorpusMaster :: FlowCmdM env ServantErr m => TermType Lang -> [HyperdataDocument] -> m [NodeId]
flowCorpusMaster la hd = (insertMasterDocs la) $ (map addUniqIdsDoc) hd
flowCorpusMaster la hd = insertMasterDocs la hd
flowCorpusUser :: FlowCmdM env ServantErr m => Username -> CorpusName -> [NodeId] -> m CorpusId
......@@ -134,8 +134,8 @@ flowCorpusUser userName corpusName ids = do
insertMasterDocs :: FlowCmdM env ServantErr m
=> TermType Lang -> [HyperdataDocument] -> m [DocId]
insertMasterDocs lang hs = do
let hyperdataDocuments' = map (\h -> ToDbDocument h) hs
let hs' = map addUniqIdsDoc hs
let hyperdataDocuments' = map (\h -> ToDbDocument h) hs'
(masterUserId, _, masterCorpusId) <- getOrMkRootWithCorpus userMaster corpusMasterName
ids <- insertDocuments masterUserId masterCorpusId NodeDocument hyperdataDocuments'
......
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