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
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
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
8438f4b7
Commit
8438f4b7
authored
Oct 17, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BASQHL] refacto.
parent
06805289
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
110 additions
and
83 deletions
+110
-83
Node.hs
src/Gargantext/API/Node.hs
+3
-3
Bashql.hs
src/Gargantext/Database/Bashql.hs
+33
-22
Flow.hs
src/Gargantext/Database/Flow.hs
+23
-28
Node.hs
src/Gargantext/Database/Node.hs
+46
-28
Node.hs
src/Gargantext/Database/Types/Node.hs
+3
-0
User.hs
src/Gargantext/Database/User.hs
+0
-1
Stop.hs
src/Gargantext/Text/Terms/Stop.hs
+2
-1
No files found.
src/Gargantext/API/Node.hs
View file @
8438f4b7
...
@@ -102,7 +102,7 @@ type NodeAPI = Get '[JSON] (Node Value)
...
@@ -102,7 +102,7 @@ type NodeAPI = Get '[JSON] (Node Value)
:>
Put
'[
J
SON
]
[
Int
]
:>
Put
'[
J
SON
]
[
Int
]
:<|>
Summary
" PostNode Node with ParentId as {id}"
:<|>
Summary
" PostNode Node with ParentId as {id}"
:>
ReqBody
'[
J
SON
]
PostNode
:>
ReqBody
'[
J
SON
]
PostNode
:>
Post
'[
J
SON
]
Int
:>
Post
'[
J
SON
]
[
Int
]
:<|>
Put
'[
J
SON
]
Int
:<|>
Put
'[
J
SON
]
Int
:<|>
Delete
'[
J
SON
]
Int
:<|>
Delete
'[
J
SON
]
Int
:<|>
"children"
:>
Summary
" Summary children"
:<|>
"children"
:>
Summary
" Summary children"
...
@@ -186,8 +186,8 @@ rename c nId (RenameNode name) = liftIO $ U.update (U.Rename nId name) c
...
@@ -186,8 +186,8 @@ rename c nId (RenameNode name) = liftIO $ U.update (U.Rename nId name) c
nodesAPI
::
Connection
->
[
NodeId
]
->
Server
NodesAPI
nodesAPI
::
Connection
->
[
NodeId
]
->
Server
NodesAPI
nodesAPI
conn
ids
=
deleteNodes'
conn
ids
nodesAPI
conn
ids
=
deleteNodes'
conn
ids
postNode
::
Connection
->
NodeId
->
PostNode
->
Handler
Int
postNode
::
Connection
->
NodeId
->
PostNode
->
Handler
[
Int
]
postNode
c
pId
(
PostNode
name
nt
)
=
liftIO
$
mk
c
nt
pId
name
postNode
c
pId
(
PostNode
name
nt
)
=
liftIO
$
mk
c
nt
(
Just
pId
)
name
putNode
::
Connection
->
NodeId
->
Handler
Int
putNode
::
Connection
->
NodeId
->
Handler
Int
putNode
=
undefined
-- TODO
putNode
=
undefined
-- TODO
...
...
src/Gargantext/Database/Bashql.hs
View file @
8438f4b7
...
@@ -69,17 +69,18 @@ module Gargantext.Database.Bashql ( get
...
@@ -69,17 +69,18 @@ module Gargantext.Database.Bashql ( get
,
put
,
put
,
rename
,
rename
,
tree
,
tree
,
mkCorpus
,
mkAnnuaire
--
, mkCorpus, mkAnnuaire
,
runCmd'
,
runCmd'
)
)
where
where
import
Control.Monad.Reader
-- (Reader, ask)
import
Control.Monad.Reader
-- (Reader, ask)
import
Safe
(
lastMay
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Data.Aeson
import
Data.Aeson
import
Data.Aeson.Types
import
Data.Aeson.Types
import
Data.List
(
last
,
conca
t
)
import
Data.List
(
concat
,
las
t
)
import
Gargantext.Core.Types
import
Gargantext.Core.Types
import
Gargantext.Database.Utils
(
connectGargandb
)
import
Gargantext.Database.Utils
(
connectGargandb
)
...
@@ -124,16 +125,18 @@ tree p = do
...
@@ -124,16 +125,18 @@ tree p = do
post
::
PWD
->
[
NodeWrite'
]
->
Cmd
Int64
post
::
PWD
->
[
NodeWrite'
]
->
Cmd
Int64
post
[]
_
=
pure
0
post
[]
_
=
pure
0
post
_
[]
=
pure
0
post
_
[]
=
pure
0
post
pth
ns
=
Cmd
.
ReaderT
$
mkNode
(
last
pth
)
ns
post
pth
ns
=
Cmd
.
ReaderT
$
mkNode
(
Just
$
last
pth
)
ns
--postR :: PWD -> [NodeWrite'] -> Cmd [Int]
--postR :: PWD -> [NodeWrite'] -> Cmd [Int]
--postR [] _ _ = pure [0]
--postR [] _ _ = pure [0]
--postR _ [] _ = pure [0]
--postR _ [] _ = pure [0]
--postR pth ns c = mkNodeR (last pth) ns c
--postR pth ns c = mkNodeR (last pth) ns c
-- | WIP
-- rm : mv to trash
-- del : empty trash
--rm :: Connection -> PWD -> [NodeId] -> IO Int
--rm :: Connection -> PWD -> [NodeId] -> IO Int
--rm = del
--rm = del
del
::
[
NodeId
]
->
Cmd
Int
del
::
[
NodeId
]
->
Cmd
Int
del
[]
=
pure
0
del
[]
=
pure
0
del
ns
=
deleteNodes
ns
del
ns
=
deleteNodes
ns
...
@@ -151,24 +154,32 @@ put u = mkCmd $ U.update u
...
@@ -151,24 +154,32 @@ put u = mkCmd $ U.update u
type
Name
=
Text
type
Name
=
Text
mkCorpus
::
ToJSON
a
=>
Name
->
(
a
->
Text
)
->
[
a
]
->
Cmd
NewNode
--mkCorpus :: ToJSON a => Name -> (a -> Text) -> [a] -> Cmd NewNode
mkCorpus
name
title
ns
=
do
--mkCorpus name title ns = do
pid
<-
last
<$>
home
-- pid <- home
let
uid
=
1
--
postNode
uid
pid
(
Node'
NodeCorpus
name
emptyObject
-- let pid' = case lastMay pid of
(
map
(
\
n
->
Node'
Document
(
title
n
)
(
toJSON
n
)
[]
)
ns
)
-- Nothing -> printDebug "No home for" name
)
-- Just p -> p
--
-- |
-- let uid = 1
-- import IMTClient as C
-- postNode uid (Just pid') ( Node' NodeCorpus name emptyObject
-- postAnnuaire "Annuaire IMT" (\n -> (maybe "" identity (C.prenom n)) <> " " <> (maybe "" identity (C.nom n))) (take 30 annuaire)
-- (map (\n -> Node' Document (title n) (toJSON n) []) ns)
mkAnnuaire
::
ToJSON
a
=>
Name
->
(
a
->
Text
)
->
[
a
]
->
Cmd
NewNode
-- )
mkAnnuaire
name
title
ns
=
do
--
pid
<-
last
<$>
home
---- |
let
uid
=
1
---- import IMTClient as C
postNode
uid
pid
(
Node'
Annuaire
name
emptyObject
---- postAnnuaire "Annuaire IMT" (\n -> (maybe "" identity (C.prenom n)) <> " " <> (maybe "" identity (C.nom n))) (take 30 annuaire)
(
map
(
\
n
->
Node'
UserPage
(
title
n
)
(
toJSON
n
)
[]
)
ns
)
--mkAnnuaire :: ToJSON a => Name -> (a -> Text) -> [a] -> Cmd NewNode
)
--mkAnnuaire name title ns = do
-- pid <- lastMay <$> home
-- let pid' = case lastMay pid of
-- Nothing -> printDebug "No home for" name
-- Just p -> p
-- let uid = 1
-- postNode uid (Just pid') ( Node' Annuaire name emptyObject
-- (map (\n -> Node' UserPage (title n) (toJSON n) []) ns)
-- )
--------------------------------------------------------------
--------------------------------------------------------------
-- |
-- |
...
...
src/Gargantext/Database/Flow.hs
View file @
8438f4b7
...
@@ -27,30 +27,38 @@ authors
...
@@ -27,30 +27,38 @@ authors
-}
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Database.Flow
module
Gargantext.Database.Flow
where
where
import
GHC.Base
((
>>
))
import
Data.Maybe
(
Maybe
(
..
))
import
Data.Maybe
(
Maybe
(
..
))
import
Gargantext.Core.Types
(
NodePoly
(
..
))
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Database.Bashql
(
runCmd'
)
import
Gargantext.Database.Bashql
(
runCmd'
)
import
Gargantext.Database.Node
(
Cmd
(
..
),
getRoot
User
)
import
Gargantext.Database.Node
(
Cmd
(
..
),
getRoot
,
mkRoot
)
import
Gargantext.Database.User
(
getUser
,
UserLight
(
..
))
import
Gargantext.Database.User
(
getUser
,
UserLight
(
..
))
import
Gargantext.Database.Node.Document.Import
(
insertDocuments
)
import
Gargantext.Database.Node.Document.Import
(
insertDocuments
)
--flow :: IO ()
flow
=
do
flow
=
do
gargantua_id
<-
runCmd'
(
getUser
"gargantua"
)
masterUser
<-
runCmd'
(
getUser
"gargantua"
)
-- createUser
userNode
<-
case
gargantua_id
of
let
masterUserId
=
case
masterUser
of
Nothing
->
panic
"no user"
Nothing
->
panic
"no user"
Just
userId
->
runCmd'
(
getRootUser
$
userLight_id
userId
)
Just
user
->
userLight_id
user
root
<-
map
node_id
<$>
runCmd'
(
getRoot
masterUserId
)
case
userNode
of
root'
<-
case
root
of
[]
->
pure
()
[]
->
runCmd'
(
mkRoot
masterUserId
)
_
->
pure
()
un
->
case
length
un
>=
2
of
True
->
panic
"Error: more than 1 userNode / user"
False
->
pure
root
printDebug
"User Node : "
root'
-- getOrMk
pure
()
--rootId <- runCmd' (getNodeWith userId nodeType)
{-
{-
rootId <- mk NodeUser gargantua_id "Node Gargantua"
rootId <- mk NodeUser gargantua_id "Node Gargantua"
...
@@ -59,24 +67,11 @@ flow = do
...
@@ -59,24 +67,11 @@ flow = do
corpusId <- mk Corpus folderId (Name "WOS") (Descr "WOS database description")
corpusId <- mk Corpus folderId (Name "WOS") (Descr "WOS database description")
docs <- parseDocuments WOS "doc/.."
docs <- parseDocuments WOS "doc/.."
ids
<- addDocuments corpusId
docs
ids
<- add (Documents corpusId)
docs
user_id <- runCmd' (get RootUser "alexandre")
user_id <- runCmd' (get RootUser "alexandre")
rootUser_id <- runCmd' (getRootUser $ userLight_id user_id
corpusId <- mk Corpus
-}
-}
src/Gargantext/Database/Node.hs
View file @
8438f4b7
...
@@ -23,7 +23,7 @@ Portability : POSIX
...
@@ -23,7 +23,7 @@ Portability : POSIX
module
Gargantext.Database.Node
where
module
Gargantext.Database.Node
where
import
Data.Text
(
pack
)
import
GHC.Int
(
Int64
)
import
GHC.Int
(
Int64
)
import
Data.Maybe
import
Data.Maybe
import
Data.Time
(
UTCTime
)
import
Data.Time
(
UTCTime
)
...
@@ -35,13 +35,13 @@ import Database.PostgreSQL.Simple.FromField ( Conversion
...
@@ -35,13 +35,13 @@ import Database.PostgreSQL.Simple.FromField ( Conversion
)
)
import
Prelude
hiding
(
null
,
id
,
map
,
sum
)
import
Prelude
hiding
(
null
,
id
,
map
,
sum
)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Types
import
Gargantext.Core.Types
import
Gargantext.Database.Types.Node
(
NodeType
)
import
Gargantext.Database.Types.Node
(
NodeType
)
import
Gargantext.Database.Queries
import
Gargantext.Database.Queries
import
Gargantext.Database.Config
(
nodeTypeId
)
import
Gargantext.Database.Config
(
nodeTypeId
)
import
Gargantext.Prelude
hiding
(
sum
)
import
Gargantext.Prelude
hiding
(
sum
)
import
Database.PostgreSQL.Simple.Internal
(
Field
)
import
Database.PostgreSQL.Simple.Internal
(
Field
)
import
Control.Applicative
(
Applicative
)
import
Control.Applicative
(
Applicative
)
import
Control.Arrow
(
returnA
)
import
Control.Arrow
(
returnA
)
...
@@ -153,7 +153,7 @@ nodeTable = Table "nodes" (pNode Node { node_id = optional "id"
...
@@ -153,7 +153,7 @@ nodeTable = Table "nodes" (pNode Node { node_id = optional "id"
nodeTable'
::
Table
(
Maybe
(
Column
PGInt4
)
nodeTable'
::
Table
(
Maybe
(
Column
PGInt4
)
,
Column
PGInt4
,
Column
PGInt4
,
Column
PGInt4
,
Column
PGInt4
,
Column
PGInt4
,
Maybe
(
Column
PGInt4
)
,
Column
PGText
,
Column
PGText
,
Maybe
(
Column
PGTimestamptz
)
,
Maybe
(
Column
PGTimestamptz
)
,
Column
PGJsonb
,
Column
PGJsonb
...
@@ -170,7 +170,7 @@ nodeTable' :: Table (Maybe (Column PGInt4)
...
@@ -170,7 +170,7 @@ nodeTable' :: Table (Maybe (Column PGInt4)
nodeTable'
=
Table
"nodes"
(
PP
.
p7
(
optional
"id"
nodeTable'
=
Table
"nodes"
(
PP
.
p7
(
optional
"id"
,
required
"typename"
,
required
"typename"
,
required
"user_id"
,
required
"user_id"
,
required
"parent_id"
,
optional
"parent_id"
,
required
"name"
,
required
"name"
,
optional
"date"
,
optional
"date"
,
required
"hyperdata"
,
required
"hyperdata"
...
@@ -198,8 +198,8 @@ selectRootUser userId = proc () -> do
...
@@ -198,8 +198,8 @@ selectRootUser userId = proc () -> do
restrict
-<
node_typename
row
.==
(
pgInt4
$
nodeTypeId
NodeUser
)
restrict
-<
node_typename
row
.==
(
pgInt4
$
nodeTypeId
NodeUser
)
returnA
-<
row
returnA
-<
row
getRoot
User
::
UserId
->
Cmd
[
Node
HyperdataUser
]
getRoot
::
UserId
->
Cmd
[
Node
HyperdataUser
]
getRoot
User
userId
=
mkCmd
$
\
conn
->
runQuery
conn
(
selectRootUser
userId
)
getRoot
userId
=
mkCmd
$
\
conn
->
runQuery
conn
(
selectRootUser
userId
)
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | order by publication date
-- | order by publication date
...
@@ -300,36 +300,34 @@ getNodesWithType conn type_id = do
...
@@ -300,36 +300,34 @@ getNodesWithType conn type_id = do
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Quick and dirty
-- Quick and dirty
------------------------------------------------------------------------
------------------------------------------------------------------------
type
NodeWrite'
=
NodePoly
(
Maybe
Int
)
Int
Int
(
ParentId
)
Text
(
Maybe
UTCTime
)
ByteString
type
NodeWrite'
=
NodePoly
(
Maybe
Int
)
Int
Int
(
Maybe
ParentId
)
Text
(
Maybe
UTCTime
)
ByteString
--node :: UserId -> ParentId -> NodeType -> Text -> Value -> NodeWrite'
node
::
ToJSON
a
=>
UserId
->
Maybe
ParentId
->
NodeType
->
Text
->
Hyperdata
a
->
NodeWrite'
node
::
UserId
->
ParentId
->
NodeType
->
Text
->
Value
->
NodeWrite'
node
userId
parentId
nodeType
name
nodeData
=
Node
Nothing
typeId
userId
parentId
name
Nothing
byteData
node
userId
parentId
nodeType
name
nodeData
=
Node
Nothing
typeId
userId
parentId
name
Nothing
byteData
where
where
typeId
=
nodeTypeId
nodeType
typeId
=
nodeTypeId
nodeType
byteData
=
DB
.
pack
$
DBL
.
unpack
$
encode
nodeData
byteData
=
DB
.
pack
$
DBL
.
unpack
$
encode
$
unHyperdata
nodeData
node2write
::
(
Functor
f2
,
Functor
f1
)
=>
node2write
::
(
Functor
maybe1
,
Functor
maybe2
,
Functor
maybe3
)
=>
Int
->
NodePoly
(
f1
Int
)
Int
Int
parentId
Text
(
f2
UTCTime
)
ByteString
maybe1
Int
->
NodePoly
(
maybe2
Int
)
Int
Int
parentId
Text
(
maybe3
UTCTime
)
ByteString
->
(
f1
(
Column
PGInt4
),
Column
PGInt4
,
Column
PGInt4
,
->
(
maybe2
(
Column
PGInt4
),
Column
PGInt4
,
Column
PGInt4
,
Column
PGInt4
,
Column
PGText
,
f2
(
Column
PGTimestamptz
),
maybe1
(
Column
PGInt4
),
Column
PGText
,
maybe3
(
Column
PGTimestamptz
),
Column
PGJsonb
)
Column
PGJsonb
)
node2write
pid
(
Node
id
tn
ud
_
nm
dt
hp
)
=
((
pgInt4
<$>
id
)
node2write
pid
(
Node
id
tn
ud
_
nm
dt
hp
)
=
((
pgInt4
<$>
id
)
,(
pgInt4
tn
)
,(
pgInt4
tn
)
,(
pgInt4
ud
)
,(
pgInt4
ud
)
,(
pgInt4
pid
)
,(
pgInt4
<$>
pid
)
,(
pgStrictText
nm
)
,(
pgStrictText
nm
)
,(
pgUTCTime
<$>
dt
)
,(
pgUTCTime
<$>
dt
)
,(
pgStrictJSONB
hp
)
,(
pgStrictJSONB
hp
)
)
)
mkNode
::
ParentId
->
[
NodeWrite'
]
->
Connection
->
IO
Int64
mkNode
::
Maybe
ParentId
->
[
NodeWrite'
]
->
Connection
->
IO
Int64
mkNode
pid
ns
conn
=
runInsertMany
conn
nodeTable'
$
map
(
node2write
pid
)
ns
mkNode
pid
ns
conn
=
runInsertMany
conn
nodeTable'
$
map
(
node2write
pid
)
ns
mkNodeR
::
ParentId
->
[
NodeWrite'
]
->
Connection
->
IO
[
Int
]
mkNodeR
::
Maybe
ParentId
->
[
NodeWrite'
]
->
Connection
->
IO
[
Int
]
mkNodeR
pid
ns
conn
=
runInsertManyReturning
conn
nodeTable'
(
map
(
node2write
pid
)
ns
)
(
\
(
i
,
_
,
_
,
_
,
_
,
_
,
_
)
->
i
)
mkNodeR
pid
ns
conn
=
runInsertManyReturning
conn
nodeTable'
(
map
(
node2write
pid
)
ns
)
(
\
(
i
,
_
,
_
,
_
,
_
,
_
,
_
)
->
i
)
...
@@ -350,8 +348,8 @@ post c uid pid [ Node' Corpus "name" "{}" []
...
@@ -350,8 +348,8 @@ post c uid pid [ Node' Corpus "name" "{}" []
-- TODO
-- TODO
-- currently this function remove the child relation
-- currently this function remove the child relation
-- needs a Temporary type between Node' and NodeWriteT
-- needs a Temporary type between Node' and NodeWriteT
node2table
::
UserId
->
ParentId
->
Node'
->
NodeWriteT
node2table
::
UserId
->
Maybe
ParentId
->
Node'
->
NodeWriteT
node2table
uid
pid
(
Node'
nt
txt
v
[]
)
=
(
Nothing
,
(
pgInt4
$
nodeTypeId
nt
),
(
pgInt4
uid
),
(
pgInt4
pid
)
node2table
uid
pid
(
Node'
nt
txt
v
[]
)
=
(
Nothing
,
(
pgInt4
$
nodeTypeId
nt
),
(
pgInt4
uid
),
(
fmap
pgInt4
pid
)
,
pgStrictText
txt
,
Nothing
,
pgStrictJSONB
$
DB
.
pack
$
DBL
.
unpack
$
encode
v
)
,
pgStrictText
txt
,
Nothing
,
pgStrictJSONB
$
DB
.
pack
$
DBL
.
unpack
$
encode
v
)
node2table
_
_
(
Node'
_
_
_
_
)
=
panic
"node2table: should not happen, Tree insert not implemented yet"
node2table
_
_
(
Node'
_
_
_
_
)
=
panic
"node2table: should not happen, Tree insert not implemented yet"
...
@@ -364,10 +362,12 @@ data Node' = Node' { _n_type :: NodeType
...
@@ -364,10 +362,12 @@ data Node' = Node' { _n_type :: NodeType
type
NodeWriteT
=
(
Maybe
(
Column
PGInt4
)
type
NodeWriteT
=
(
Maybe
(
Column
PGInt4
)
,
Column
PGInt4
,
Column
PGInt4
,
Column
PGInt4
,
Column
PGInt4
,
Column
PGText
,
Column
PGInt4
,
Maybe
(
Column
PGInt4
)
,
Column
PGText
,
Maybe
(
Column
PGTimestamptz
)
,
Maybe
(
Column
PGTimestamptz
)
,
Column
PGJsonb
,
Column
PGJsonb
)
)
...
@@ -381,7 +381,7 @@ data NewNode = NewNode { _newNodeId :: Int
...
@@ -381,7 +381,7 @@ data NewNode = NewNode { _newNodeId :: Int
,
_newNodeChildren
::
[
Int
]
}
,
_newNodeChildren
::
[
Int
]
}
-- | postNode
-- | postNode
postNode
::
UserId
->
ParentId
->
Node'
->
Cmd
NewNode
postNode
::
UserId
->
Maybe
ParentId
->
Node'
->
Cmd
NewNode
postNode
uid
pid
(
Node'
nt
txt
v
[]
)
=
do
postNode
uid
pid
(
Node'
nt
txt
v
[]
)
=
do
pids
<-
mkNodeR'
[
node2table
uid
pid
(
Node'
nt
txt
v
[]
)]
pids
<-
mkNodeR'
[
node2table
uid
pid
(
Node'
nt
txt
v
[]
)]
case
pids
of
case
pids
of
...
@@ -401,12 +401,30 @@ postNode _ _ (Node' _ _ _ _) = panic "TODO: postNode for this type not implement
...
@@ -401,12 +401,30 @@ postNode _ _ (Node' _ _ _ _) = panic "TODO: postNode for this type not implement
childWith
::
UserId
->
ParentId
->
Node'
->
NodeWriteT
childWith
::
UserId
->
ParentId
->
Node'
->
NodeWriteT
childWith
uId
pId
(
Node'
Document
txt
v
[]
)
=
node2table
uId
pId
(
Node'
Document
txt
v
[]
)
childWith
uId
pId
(
Node'
Document
txt
v
[]
)
=
node2table
uId
(
Just
pId
)
(
Node'
Document
txt
v
[]
)
childWith
uId
pId
(
Node'
UserPage
txt
v
[]
)
=
node2table
uId
pId
(
Node'
UserPage
txt
v
[]
)
childWith
uId
pId
(
Node'
UserPage
txt
v
[]
)
=
node2table
uId
(
Just
pId
)
(
Node'
UserPage
txt
v
[]
)
childWith
_
_
(
Node'
_
_
_
_
)
=
panic
"This NodeType can not be a child"
childWith
_
_
(
Node'
_
_
_
_
)
=
panic
"This NodeType can not be a child"
mk
::
Connection
->
NodeType
->
ParentId
->
Text
->
IO
Int
-- TODO: remove hardcoded userId (with Reader)
mk
c
nt
pId
name
=
fromIntegral
<$>
mkNode
pId
[
node
1
pId
nt
name
""
]
c
-- TODO: user Reader in the API and adapt this function
mk
::
Connection
->
NodeType
->
Maybe
ParentId
->
Text
->
IO
[
Int
]
mk
c
nt
pId
name
=
mk'
c
nt
1
pId
name
mk'
::
Connection
->
NodeType
->
UserId
->
Maybe
ParentId
->
Text
->
IO
[
Int
]
mk'
c
nt
uId
pId
name
=
map
fromIntegral
<$>
mkNodeR
pId
[
node
uId
pId
nt
name
hd
]
c
where
hd
=
Hyperdata
(
HyperdataUser
(
Just
$
(
pack
.
show
)
EN
))
type
Name
=
Text
mk''
::
NodeType
->
Maybe
ParentId
->
UserId
->
Name
->
Cmd
[
Int
]
mk''
NodeUser
Nothing
uId
name
=
mkCmd
$
\
c
->
mk'
c
NodeUser
uId
Nothing
name
mk''
NodeUser
_
_
_
=
panic
"NodeUser can not has a parent"
mk''
_
Nothing
_
_
=
panic
"NodeType needs a parent"
mk''
nt
pId
uId
name
=
mkCmd
$
\
c
->
mk'
c
nt
uId
pId
name
mkRoot
::
UserId
->
Cmd
[
Int
]
mkRoot
uId
=
case
uId
>
0
of
False
->
panic
"UserId <= 0"
True
->
mk''
NodeUser
Nothing
uId
(
"User Node : "
<>
(
pack
.
show
)
uId
)
src/Gargantext/Database/Types/Node.hs
View file @
8438f4b7
...
@@ -191,6 +191,9 @@ instance Arbitrary Resource where
...
@@ -191,6 +191,9 @@ instance Arbitrary Resource where
------------------------------------------------------------------------
------------------------------------------------------------------------
data
Hyperdata
a
=
Hyperdata
{
unHyperdata
::
a
}
$
(
deriveJSON
(
unPrefix
""
)
''
H
yperdata
)
data
HyperdataCorpus
=
HyperdataCorpus
{
hyperdataCorpus_resources
::
[
Resource
]
data
HyperdataCorpus
=
HyperdataCorpus
{
hyperdataCorpus_resources
::
[
Resource
]
}
deriving
(
Show
,
Generic
)
}
deriving
(
Show
,
Generic
)
$
(
deriveJSON
(
unPrefix
"hyperdataCorpus_"
)
''
H
yperdataCorpus
)
$
(
deriveJSON
(
unPrefix
"hyperdataCorpus_"
)
''
H
yperdataCorpus
)
...
...
src/Gargantext/Database/User.hs
View file @
8438f4b7
...
@@ -32,7 +32,6 @@ import Data.Text (Text)
...
@@ -32,7 +32,6 @@ import Data.Text (Text)
import
Data.Time
(
UTCTime
)
import
Data.Time
(
UTCTime
)
import
GHC.Show
(
Show
(
..
))
import
GHC.Show
(
Show
(
..
))
import
Opaleye
import
Opaleye
import
qualified
Database.PostgreSQL.Simple
as
PGS
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Gargantext.Database.Node
(
Cmd
(
..
),
mkCmd
,
runCmd
)
import
Gargantext.Database.Node
(
Cmd
(
..
),
mkCmd
,
runCmd
)
...
...
src/Gargantext/Text/Terms/Stop.hs
View file @
8438f4b7
...
@@ -14,8 +14,9 @@ Main type here is String.
...
@@ -14,8 +14,9 @@ Main type here is String.
-}
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
module
Gargantext.Text.Terms.Stop
(
detectLang
,
detectLangs
,
stopList
)
module
Gargantext.Text.Terms.Stop
--
(detectLang, detectLangs, stopList)
where
where
import
GHC.Base
(
Functor
)
import
GHC.Base
(
Functor
)
...
...
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