2 Module : Gargantext.Database.Flow
3 Description : Database Flow
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
12 add :: Corpus -> [Documents] -> IO Int
13 if new id -> extractNgrams + extract Authors + extract Sources
15 insert Ngrams -> NgramsId
16 Map (NgramsId, NodeId) -> insert
18 data NgramsType = Sources | Authors | Terms
20 nodes_ngrams : column type, column list
29 {-# LANGUAGE NoImplicitPrelude #-}
30 {-# LANGUAGE OverloadedStrings #-}
32 module Gargantext.Database.Flow
34 import GHC.Base ((>>))
35 import Data.Maybe (Maybe(..))
36 import Gargantext.Core.Types (NodePoly(..))
37 import Gargantext.Prelude
38 import Gargantext.Database.Bashql (runCmd')
39 import Gargantext.Database.Node (Cmd(..), getRoot, mkRoot)
40 import Gargantext.Database.User (getUser, UserLight(..))
41 import Gargantext.Database.Node.Document.Import (insertDocuments)
45 masterUser <- runCmd' (getUser "gargantua")
47 let masterUserId = case masterUser of
48 Nothing -> panic "no user"
49 Just user -> userLight_id user
51 root <- map node_id <$> runCmd' (getRoot masterUserId)
54 [] -> runCmd' (mkRoot masterUserId)
55 un -> case length un >= 2 of
56 True -> panic "Error: more than 1 userNode / user"
59 printDebug "User Node : " root'
63 rootId <- mk NodeUser gargantua_id "Node Gargantua"
65 --folderId <- mk Folder parentId (Name "Data") (Descr "All corpora DATA here")
66 folderId <- mk Folder rootId "Data"
67 corpusId <- mk Corpus folderId (Name "WOS") (Descr "WOS database description")
69 docs <- parseDocuments WOS "doc/.."
70 ids <- add (Documents corpusId) docs
72 user_id <- runCmd' (get RootUser "alexandre")
73 rootUser_id <- runCmd' (getRootUser $ userLight_id user_id