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

[FLOW][DB][LIST] creating subflow for list

[FLOW][TEXT] mv file in Text folder
parent 2996a7df
...@@ -62,7 +62,7 @@ import Gargantext.Database.Facet (FacetDoc , runViewDocuments', OrderBy(..) ...@@ -62,7 +62,7 @@ import Gargantext.Database.Facet (FacetDoc , runViewDocuments', OrderBy(..)
import Gargantext.Database.Tree (treeDB, HasTreeError(..), TreeError(..)) import Gargantext.Database.Tree (treeDB, HasTreeError(..), TreeError(..))
import Gargantext.Database.NodeNode (nodesToFavorite, nodesToTrash) import Gargantext.Database.NodeNode (nodesToFavorite, nodesToTrash)
-- Graph -- Graph
import Gargantext.TextFlow import Gargantext.Text.Flow
import Gargantext.Viz.Graph (Graph) import Gargantext.Viz.Graph (Graph)
import Gargantext.Core (Lang(..)) import Gargantext.Core (Lang(..))
import Gargantext.Core.Types (Offset, Limit) import Gargantext.Core.Types (Offset, Limit)
......
...@@ -35,7 +35,7 @@ import Gargantext.Core.Types (NodePoly(..)) ...@@ -35,7 +35,7 @@ import Gargantext.Core.Types (NodePoly(..))
import Gargantext.Prelude import Gargantext.Prelude
import Gargantext.Database.Bashql (runCmd', del) import Gargantext.Database.Bashql (runCmd', del)
import Gargantext.Database.Types.Node (Node(..), HyperdataDocument(..)) import Gargantext.Database.Types.Node (Node(..), HyperdataDocument(..))
import Gargantext.Database.Node (getRoot, mkRoot, mkCorpus, Cmd(..)) import Gargantext.Database.Node (getRoot, mkRoot, mkCorpus, Cmd(..), mkList)
import Gargantext.Database.User (getUser, UserLight(..), Username) import Gargantext.Database.User (getUser, UserLight(..), Username)
import Gargantext.Database.Node.Document.Insert (insertDocuments, ReturnId(..), addUniqIds) import Gargantext.Database.Node.Document.Insert (insertDocuments, ReturnId(..), addUniqIds)
import Gargantext.Database.Node.Document.Add (add) import Gargantext.Database.Node.Document.Add (add)
...@@ -47,6 +47,26 @@ type UserId = Int ...@@ -47,6 +47,26 @@ type UserId = Int
type RootId = Int type RootId = Int
type CorpusId = Int type CorpusId = Int
flow :: FilePath -> IO Int
flow fp = do
(masterUserId, _, corpusId) <- subFlow "gargantua"
docs <- map addUniqIds <$> parseDocs WOS fp
ids <- runCmd' $ insertDocuments masterUserId corpusId docs
printDebug "Docs IDs : " ids
idsRepeat <- runCmd' $ insertDocuments masterUserId corpusId docs
printDebug "Docs IDs : " idsRepeat
(_, _, corpusId2) <- subFlow "alexandre"
inserted <- runCmd' $ add corpusId2 (map reId ids)
printDebug "Inserted : " inserted
runCmd' $ del [corpusId2, corpusId]
subFlow :: Username -> IO (UserId, RootId, CorpusId) subFlow :: Username -> IO (UserId, RootId, CorpusId)
subFlow username = do subFlow username = do
maybeUserId <- runCmd' (getUser username) maybeUserId <- runCmd' (getUser username)
...@@ -72,29 +92,10 @@ subFlow username = do ...@@ -72,29 +92,10 @@ subFlow username = do
(username, userId, rootId, corpusId) (username, userId, rootId, corpusId)
pure (userId, rootId, corpusId) pure (userId, rootId, corpusId)
flow :: FilePath -> IO Int
flow fp = do
(masterUserId, _, corpusId) <- subFlow "gargantua"
docs <- map addUniqIds <$> parseDocs WOS fp
ids <- runCmd' $ insertDocuments masterUserId corpusId docs
printDebug "Docs IDs : " ids
idsRepeat <- runCmd' $ insertDocuments masterUserId corpusId docs
printDebug "Docs IDs : " idsRepeat
(_, _, corpusId2) <- subFlow "alexandre"
inserted <- runCmd' $ add corpusId2 (map reId ids)
printDebug "Inserted : " inserted
runCmd' $ del [corpusId2, corpusId]
---------------------------------------------------------------- ----------------------------------------------------------------
type HashId = Text type HashId = Text
type NodeId = Int type NodeId = Int
type ListId = Int
type ToInsert = Map HashId HyperdataDocument type ToInsert = Map HashId HyperdataDocument
type Inserted = Map HashId ReturnId type Inserted = Map HashId ReturnId
...@@ -148,14 +149,23 @@ insertToNodeNgrams m = insertNodeNgrams $ [ NodeNgram Nothing nId ((_ngramsId ...@@ -148,14 +149,23 @@ insertToNodeNgrams m = insertNodeNgrams $ [ NodeNgram Nothing nId ((_ngramsId
, (nId, n) <- DM.toList nId2int , (nId, n) <- DM.toList nId2int
] ]
-- mk ListGroup listFlow :: UserId -> CorpusId -> Map (NgramsT NgramsIndexed) (Map NodeId Int) -> Cmd [ListId]
-- groupBy fun listFlow uId cId ng = do
-- insertInto NodeNgramsNgrams lId <- mkList cId uId
-- groupNgramsBy fun
-- insertGroups = NodeNgramsNgrams
pure lId
-- compute Candidate / Map -- compute Candidate / Map
-- ALTER TABLE nodes_nodes_ngrams ADD COLUMN typelist int; -- ALTER TABLE nodes_nodes_ngrams ADD COLUMN typelist int;
-- insertNodeNodeNgram -- insertLists = NodeNodeNgram
-- | TODO ask on meeting
-- get data of NgramsTable -- get data of NgramsTable
-- post :: update NodeNodeNgrams -- post :: update NodeNodeNgrams
-- group ngrams -- group ngrams
......
{-| {-|
Module : Gargantext.TextFlow Module : Gargantext.Text.Flow
Description : Server API Description : Server API
Copyright : (c) CNRS, 2017-Present Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3 License : AGPL + CECILL v3
...@@ -14,7 +14,7 @@ From text to viz, all the flow of texts in Gargantext. ...@@ -14,7 +14,7 @@ From text to viz, all the flow of texts in Gargantext.
{-# OPTIONS_GHC -fno-warn-name-shadowing #-} {-# OPTIONS_GHC -fno-warn-name-shadowing #-}
{-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE NoImplicitPrelude #-}
module Gargantext.TextFlow module Gargantext.Text.Flow
where where
import GHC.IO (FilePath) import GHC.IO (FilePath)
......
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