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
ac515447
Commit
ac515447
authored
Jun 18, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BASHQL] can post Corpus with its Documents as children (simple and naive implementation).
parent
0e129af0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
25 additions
and
22 deletions
+25
-22
Database.hs
src/Gargantext/Database.hs
+13
-12
Node.hs
src/Gargantext/Database/Node.hs
+12
-10
No files found.
src/Gargantext/Database.hs
View file @
ac515447
...
...
@@ -97,12 +97,11 @@ home c = map node_id <$> getNodesWithParentId c 0 Nothing
ls
::
Connection
->
PWD
->
IO
[
Node
Value
]
ls
=
get
tree
::
Connection
->
PWD
->
IO
[[
Node
Value
]]
tree
c
=
undefined
-- | TODO
-- post User
-- post Dir
-- post Corpus Parent_id (Empty|MyData)
-- post CorpusWith
-- post List
post
::
Connection
->
PWD
->
[
NodeWrite'
]
->
IO
Int64
post
_
[]
_
=
pure
0
post
_
_
[]
=
pure
0
...
...
@@ -148,14 +147,16 @@ ls' = do
type
Children
a
=
Maybe
a
post'
::
IO
Int64
post'
::
IO
[
Int
]
post'
=
do
c
<-
connectGargandb
"gargantext.ini"
h
<-
home
c
let
userId
=
1
post
c
h
[
node
userId
(
last
h
)
Corpus
"name"
"{}"
,
node
userId
(
last
h
)
Project
"name"
"{}"
]
c
<-
connectGargandb
"gargantext.ini"
pid
<-
last
<$>
home
c
let
uid
=
1
postNode
c
uid
pid
(
Node'
Corpus
"Premier corpus"
"{}"
[
Node'
Document
"Doc1"
"{}"
[]
,
Node'
Document
"Doc2"
"{}"
[]
,
Node'
Document
"Doc3"
"{}"
[]
]
)
postR'
::
IO
[
Int
]
...
...
src/Gargantext/Database/Node.hs
View file @
ac515447
...
...
@@ -285,17 +285,10 @@ post c uid pid [ Node' Corpus "name" "{}" []
-- TODO
-- currently this function remove the child relation
-- needs a Temporary type between Node' and NodeWriteT
node2table
'
::
UserId
->
ParentId
->
Node'
->
[
NodeWriteT
]
node2table
'
uid
pid
(
Node'
nt
txt
v
[]
)
=
[(
Nothing
,
(
pgInt4
$
nodeTypeId
nt
),
(
pgInt4
uid
),
(
pgInt4
pid
)
node2table
::
UserId
->
ParentId
->
Node'
->
[
NodeWriteT
]
node2table
uid
pid
(
Node'
nt
txt
v
[]
)
=
[(
Nothing
,
(
pgInt4
$
nodeTypeId
nt
),
(
pgInt4
uid
),
(
pgInt4
pid
)
,
pgStrictText
txt
,
Nothing
,
pgStrictJSONB
$
DB
.
pack
$
DBL
.
unpack
$
encode
v
)]
node2table'
uid
pid
(
Node'
nt
txt
v
(
c
:
cs
))
=
node2table'
uid
pid
(
Node'
nt
txt
v
[]
)
<>
node2table'
uid
pid
c
<>
node2table'
uid
pid
(
Node'
nt
txt
v
cs
)
nodes2table
::
UserId
->
ParentId
->
[
Node'
]
->
[[
NodeWriteT
]]
nodes2table
_
_
[]
=
[]
nodes2table
uid
pid
ns
=
map
(
node2table'
uid
pid
)
ns
node2table
_
_
(
Node'
_
_
_
_
)
=
panic
"node2table: should not happen, Tree insert not implemented yet"
data
Node'
=
Node'
{
_n_type
::
NodeType
...
...
@@ -319,5 +312,14 @@ mkNode' conn ns = runInsertMany conn nodeTable' ns
mkNodeR'
::
Connection
->
[
NodeWriteT
]
->
IO
[
Int
]
mkNodeR'
conn
ns
=
runInsertManyReturning
conn
nodeTable'
ns
(
\
(
i
,
_
,
_
,
_
,
_
,
_
,
_
)
->
i
)
postNode
::
Connection
->
UserId
->
ParentId
->
Node'
->
IO
[
Int
]
postNode
c
uid
pid
(
Node'
nt
txt
v
[]
)
=
mkNodeR'
c
(
node2table
uid
pid
(
Node'
nt
txt
v
[]
))
postNode
c
uid
pid
(
Node'
Corpus
txt
v
ns
)
=
do
[
pid'
]
<-
postNode
c
uid
pid
(
Node'
Corpus
txt
v
[]
)
pids
<-
mkNodeR'
c
$
concat
$
(
map
(
\
(
Node'
Document
txt
v
_
)
->
node2table
uid
pid'
$
Node'
Document
txt
v
[]
)
ns
)
pure
(
pids
)
postNode
c
uid
pid
(
Node'
_
_
_
_
)
=
panic
"postNode for this type not implemented yet"
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