Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
145
Issues
145
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
8230bdee
Unverified
Commit
8230bdee
authored
Oct 18, 2018
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'dbflow' of
https://gitlab.iscpif.fr/gargantext/haskell-gargantext
into dbflow
parents
10f9f394
670baca2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
34 additions
and
15 deletions
+34
-15
Flow.hs
src/Gargantext/Database/Flow.hs
+32
-15
User.hs
src/Gargantext/Database/User.hs
+2
-0
No files found.
src/Gargantext/Database/Flow.hs
View file @
8230bdee
...
...
@@ -30,39 +30,52 @@ authors
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Database.Flow
(
flow
)
where
import
System.FilePath
(
FilePath
)
import
GHC.Base
((
>>
))
import
Data.Maybe
(
Maybe
(
..
))
import
Gargantext.Core.Types
(
NodePoly
(
..
))
import
Gargantext.Prelude
import
Gargantext.Database.Bashql
(
runCmd'
,
del
)
import
Gargantext.Database.Node
(
getRoot
,
mkRoot
,
mk
Corpus
)
import
Gargantext.Database.User
(
getUser
,
UserLight
(
..
))
import
Gargantext.Database.Node
(
Cmd
(
..
),
getRoot
,
mkRoot
,
mkCorpus
,
default
Corpus
)
import
Gargantext.Database.User
(
getUser
,
UserLight
(
..
)
,
Username
)
import
Gargantext.Database.Node.Document.Import
(
insertDocuments
)
import
Gargantext.Text.Parsers
(
parseDocs
,
FileFormat
(
WOS
))
flow
::
FilePath
->
IO
()
flow
fp
=
do
masterUser
<-
runCmd'
(
getUser
"gargantua"
)
type
UserId
=
Int
type
RootId
=
Int
type
CorpusId
=
Int
subFlow
::
Username
->
IO
(
UserId
,
RootId
,
CorpusId
)
subFlow
username
=
do
maybeUserId
<-
runCmd'
(
getUser
username
)
let
masterUserId
=
case
masterUser
of
let
userId
=
case
maybeUserId
of
Nothing
->
panic
"Error: User does not exist (yet)"
-- mk NodeUser gargantua_id "Node Gargantua"
Just
user
->
userLight_id
user
rootId'
<-
map
_node_id
<$>
runCmd'
(
getRoot
masterU
serId
)
rootId'
<-
map
_node_id
<$>
runCmd'
(
getRoot
u
serId
)
rootId''
<-
case
rootId'
of
[]
->
runCmd'
(
mkRoot
masterU
serId
)
[]
->
runCmd'
(
mkRoot
u
serId
)
un
->
case
length
un
>=
2
of
True
->
panic
"Error: more than 1 userNode / user"
False
->
pure
rootId'
let
rootId
=
maybe
(
panic
"error rootId"
)
identity
(
head
rootId''
)
printDebug
"Root ID : "
rootId
corpusId'
<-
runCmd'
$
mkCorpus
(
Just
"Corpus WOS"
)
Nothing
rootId
masterUserId
corpusId'
<-
runCmd'
$
mkCorpus
(
Just
"Corpus WOS"
)
Nothing
rootId
userId
let
corpusId
=
maybe
(
panic
"error corpusId"
)
identity
(
head
corpusId'
)
printDebug
"Corpus ID : "
corpusId
printDebug
"(username, userId, rootId, corpusId"
(
username
,
userId
,
rootId
,
corpusId
)
pure
(
userId
,
rootId
,
corpusId
)
-- flow :: FilePath -> IO ()
flow
fp
=
do
(
masterUserId
,
_
,
corpusId
)
<-
subFlow
"gargantua"
docs
<-
parseDocs
WOS
fp
ids
<-
runCmd'
$
insertDocuments
masterUserId
corpusId
docs
...
...
@@ -71,8 +84,12 @@ flow fp = do
idsRepeat
<-
runCmd'
$
insertDocuments
masterUserId
corpusId
docs
printDebug
"Docs IDs : "
idsRepeat
_
<-
runCmd'
(
del
[
corpusId
])
pure
()
(
userId
,
rootId
,
corpusId2
)
<-
subFlow
"alexandre"
runCmd'
(
del
[
corpusId
])
{-
--folderId <- mk Folder parentId (Name "Data") (Descr "All corpora DATA here")
...
...
src/Gargantext/Database/User.hs
View file @
8230bdee
...
...
@@ -142,3 +142,5 @@ type Username = Text
getUser
::
Username
->
Cmd
(
Maybe
UserLight
)
getUser
u
=
mkCmd
$
\
c
->
userLightWithUsername
u
<$>
runCmd
c
usersLight
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment