Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Przemyslaw Kaminski
haskell-gargantext
Commits
18ceac9c
Commit
18ceac9c
authored
Oct 14, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[API][DB] rename connection.
parent
62eb01c8
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
10 deletions
+14
-10
Node.hs
src/Gargantext/API/Node.hs
+4
-3
Bashql.hs
src/Gargantext/Database/Bashql.hs
+3
-4
Update.hs
src/Gargantext/Database/Node/Update.hs
+7
-3
No files found.
src/Gargantext/API/Node.hs
View file @
18ceac9c
...
...
@@ -47,6 +47,7 @@ import Gargantext.Database.Node ( runCmd
,
getNodesWithParentId
,
getNode
,
getNodesWith
,
deleteNode
,
deleteNodes
)
import
qualified
Gargantext.Database.Node.Update
as
U
(
update
,
Update
(
..
))
import
Gargantext.Database.Facet
(
FacetDoc
,
getDocFacet
,
FacetChart
)
import
Gargantext.Database.Tree
(
treeDB
,
HasTreeError
(
..
),
TreeError
(
..
))
...
...
@@ -83,7 +84,7 @@ instance Arbitrary Rename where
type
NodeAPI
=
Get
'[
J
SON
]
(
Node
Value
)
:<|>
"rename"
:>
Summary
" Rename Node"
:>
ReqBody
'[
J
SON
]
Rename
:>
Put
'[
J
SON
]
Int
:>
Put
'[
J
SON
]
[
Int
]
:<|>
Post
'[
J
SON
]
Int
:<|>
Put
'[
J
SON
]
Int
:<|>
Delete
'[
J
SON
]
Int
...
...
@@ -162,8 +163,8 @@ nodeAPI conn id = liftIO (putStrLn ("/node" :: Text) >> getNode co
-- :<|> query
-- | Check if the name is less than 255 char
--rename :: Connection -> NodeId -> Rename -> Server NodeAPI
rename
::
Connection
->
NodeId
->
Rename
->
Handler
Int
rename
=
undefined
rename
::
Connection
->
NodeId
->
Rename
->
Handler
[
Int
]
rename
c
nId
(
Rename
name
)
=
liftIO
$
U
.
update
(
U
.
Rename
nId
name
)
c
nodesAPI
::
Connection
->
[
NodeId
]
->
Server
NodesAPI
nodesAPI
conn
ids
=
deleteNodes'
conn
ids
...
...
src/Gargantext/Database/Bashql.hs
View file @
18ceac9c
...
...
@@ -80,7 +80,6 @@ import Data.Text (Text)
import
Data.Aeson
import
Data.Aeson.Types
import
Data.List
(
last
,
concat
)
import
Database.PostgreSQL.Simple
(
Only
)
import
Gargantext.Core.Types
import
Gargantext.Database.Utils
(
connectGargandb
)
...
...
@@ -96,10 +95,10 @@ import Opaleye hiding (FromField)
type
PWD
=
[
NodeId
]
--data PWD' a = a | PWD' [a]
rename
::
NodeId
->
Text
->
Cmd
[
Only
Int
]
rename
::
NodeId
->
Text
->
Cmd
[
Int
]
rename
n
t
=
mkCmd
$
\
conn
->
U
.
update
(
U
.
Rename
n
t
)
conn
mv
::
NodeId
->
ParentId
->
Cmd
[
Only
Int
]
mv
::
NodeId
->
ParentId
->
Cmd
[
Int
]
mv
n
p
=
mkCmd
$
\
conn
->
U
.
update
(
U
.
Move
n
p
)
conn
-- | TODO get Children or Node
...
...
@@ -140,7 +139,7 @@ del [] = pure 0
del
ns
=
deleteNodes
ns
-- | TODO
put
::
U
.
Update
->
Cmd
[
Only
Int
]
put
::
U
.
Update
->
Cmd
[
Int
]
put
u
=
mkCmd
$
U
.
update
u
-- | TODO
...
...
src/Gargantext/Database/Node/Update.hs
View file @
18ceac9c
...
...
@@ -37,10 +37,14 @@ data Update = Rename NodeId Name
-- TODO : Field as parameter
-- TODO jsonb values, consider this:
-- https://stackoverflow.com/questions/26703476/how-to-perform-update-operations-on-columns-of-type-jsonb-in-postgres-9-4
update
::
Update
->
Connection
->
IO
[
Only
Int
]
update
(
Rename
nId
name
)
conn
=
query
conn
"UPDATE nodes SET name=? where id=? returning id"
unOnly
::
Only
a
->
a
unOnly
(
Only
a
)
=
a
update
::
Update
->
Connection
->
IO
[
Int
]
update
(
Rename
nId
name
)
conn
=
map
unOnly
<$>
query
conn
"UPDATE nodes SET name=? where id=? returning id"
(
DT
.
take
255
name
,
nId
)
update
(
Move
nId
pId
)
conn
=
query
conn
"UPDATE nodes SET parent_id= ? where id=? returning id"
update
(
Move
nId
pId
)
conn
=
map
unOnly
<$>
query
conn
"UPDATE nodes SET parent_id= ? where id=? returning id"
(
pId
,
nId
)
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