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
bfd3789f
Commit
bfd3789f
authored
Jun 15, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[BASHQL] value ok + returning value ok.
parent
856eb6d2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
7 deletions
+38
-7
Database.hs
src/Gargantext/Database.hs
+22
-1
Node.hs
src/Gargantext/Database/Node.hs
+16
-6
No files found.
src/Gargantext/Database.hs
View file @
bfd3789f
...
...
@@ -60,7 +60,7 @@ module Gargantext.Database ( module Gargantext.Database.Utils
,
get
,
ls
,
ls'
,
home
,
home'
,
post
,
post'
,
post
,
post'
,
postR'
,
del
,
del'
)
where
...
...
@@ -107,6 +107,12 @@ post _ [] _ = pure 0
post
_
_
[]
=
pure
0
post
c
pth
ns
=
mkNode
c
(
last
pth
)
ns
postR
::
Connection
->
PWD
->
[
NodeWrite'
]
->
IO
[
Int
]
postR
_
[]
_
=
pure
[
0
]
postR
_
_
[]
=
pure
[
0
]
postR
c
pth
ns
=
mkNodeR
c
(
last
pth
)
ns
rm
::
Connection
->
PWD
->
[
NodeId
]
->
IO
Int
rm
=
del
...
...
@@ -159,6 +165,21 @@ post' = do
data
Children
a
=
NoChildren
|
Children
a
postR'
::
IO
[
Int
]
postR'
=
do
c
<-
connectGargandb
"gargantext.ini"
h
<-
home
c
let
userId
=
1
postR
c
h
[
node
userId
(
last
h
)
Corpus
"name"
"{}"
,
node
userId
(
last
h
)
Project
"name"
"{}"
]
del'
::
[
NodeId
]
->
IO
Int
del'
ns
=
do
c
<-
connectGargandb
"gargantext.ini"
...
...
src/Gargantext/Database/Node.hs
View file @
bfd3789f
...
...
@@ -21,7 +21,7 @@ Portability : POSIX
module
Gargantext.Database.Node
where
import
Data.ByteString
(
ByteString
)
import
GHC.Int
(
Int64
)
import
Data.Maybe
import
Data.Time
(
UTCTime
)
...
...
@@ -48,7 +48,11 @@ import Data.Maybe (Maybe, fromMaybe)
import
Data.Text
(
Text
)
import
Data.Profunctor.Product.TH
(
makeAdaptorAndInstance
)
import
Data.Typeable
(
Typeable
)
import
qualified
Data.ByteString.Internal
as
DBI
import
qualified
Data.ByteString
as
DB
import
qualified
Data.ByteString.Lazy
as
DBL
import
Data.ByteString
(
ByteString
)
import
Database.PostgreSQL.Simple
(
Connection
)
import
Opaleye
hiding
(
FromField
)
import
Opaleye.Internal.QueryArr
(
Query
(
..
))
...
...
@@ -84,7 +88,7 @@ instance QueryRunnerColumnDefault PGJsonb HyperdataUser where
fromField'
::
(
Typeable
b
,
FromJSON
b
)
=>
Field
->
Maybe
DB
I
.
ByteString
->
Conversion
b
fromField'
::
(
Typeable
b
,
FromJSON
b
)
=>
Field
->
Maybe
DB
.
ByteString
->
Conversion
b
fromField'
field
mb
=
do
v
<-
fromField
field
mb
valueToHyperdata
v
...
...
@@ -236,12 +240,11 @@ type NodeWrite' = NodePoly (Maybe Int) Int Int (ParentId) Text (Maybe UTCTime) B
type
TypeId
=
Int
--node :: UserId -> ParentId -> NodeType -> Text -> Value -> NodeWrite'
node
::
UserId
->
ParentId
->
NodeType
->
Text
->
ByteString
->
NodeWrite'
node
::
UserId
->
ParentId
->
NodeType
->
Text
->
Value
->
NodeWrite'
node
userId
parentId
nodeType
name
nodeData
=
Node
Nothing
typeId
userId
parentId
name
Nothing
byteData
where
typeId
=
nodeTypeId
nodeType
byteData
=
nodeData
--byteData = encode nodeData
byteData
=
DB
.
pack
$
DBL
.
unpack
$
encode
nodeData
node2write
pid
(
Node
id
tn
ud
_
nm
dt
hp
)
=
((
pgInt4
<$>
id
)
,(
pgInt4
tn
)
...
...
@@ -255,3 +258,10 @@ node2write pid (Node id tn ud _ nm dt hp) = ((pgInt4 <$> id)
mkNode
::
Connection
->
ParentId
->
[
NodeWrite'
]
->
IO
Int64
mkNode
conn
pid
ns
=
runInsertMany
conn
nodeTable'
$
map
(
node2write
pid
)
ns
mkNodeR
::
Connection
->
ParentId
->
[
NodeWrite'
]
->
IO
[
Int
]
mkNodeR
conn
pid
ns
=
runInsertManyReturning
conn
nodeTable'
(
map
(
node2write
pid
)
ns
)
(
\
(
i
,
_
,
_
,
_
,
_
,
_
,
_
)
->
i
)
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