]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Database/Flow.hs
[BASQHL] refacto.
[gargantext.git] / src / Gargantext / Database / Flow.hs
1 {-|
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
8 Portability : POSIX
9
10
11
12 add :: Corpus -> [Documents] -> IO Int
13 if new id -> extractNgrams + extract Authors + extract Sources
14 Map (Ngrams, NodeId)
15 insert Ngrams -> NgramsId
16 Map (NgramsId, NodeId) -> insert
17
18 data NgramsType = Sources | Authors | Terms
19
20 nodes_ngrams : column type, column list
21
22
23 documents
24 sources
25 authors
26
27 -}
28
29 {-# LANGUAGE NoImplicitPrelude #-}
30 {-# LANGUAGE OverloadedStrings #-}
31
32 module Gargantext.Database.Flow
33 where
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)
42
43 --flow :: IO ()
44 flow = do
45 masterUser <- runCmd' (getUser "gargantua")
46
47 let masterUserId = case masterUser of
48 Nothing -> panic "no user"
49 Just user -> userLight_id user
50
51 root <- map node_id <$> runCmd' (getRoot masterUserId)
52
53 root' <- case root of
54 [] -> runCmd' (mkRoot masterUserId)
55 un -> case length un >= 2 of
56 True -> panic "Error: more than 1 userNode / user"
57 False -> pure root
58
59 printDebug "User Node : " root'
60
61 pure ()
62 {-
63 rootId <- mk NodeUser gargantua_id "Node Gargantua"
64
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")
68
69 docs <- parseDocuments WOS "doc/.."
70 ids <- add (Documents corpusId) docs
71
72 user_id <- runCmd' (get RootUser "alexandre")
73 rootUser_id <- runCmd' (getRootUser $ userLight_id user_id
74 corpusId <- mk Corpus
75 -}
76
77