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
1b07704e
Commit
1b07704e
authored
Apr 30, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DB/Errors] DoesNotExist Node error (todo remove useless errors type).
parent
217e984e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
12 deletions
+28
-12
Node.hs
src/Gargantext/Database/Query/Table/Node.hs
+25
-12
Error.hs
src/Gargantext/Database/Query/Table/Node/Error.hs
+3
-0
No files found.
src/Gargantext/Database/Query/Table/Node.hs
View file @
1b07704e
...
...
@@ -154,11 +154,14 @@ getNodeWith nId _ = do
<$>
runOpaQuery
(
limit
1
$
selectNode
(
pgNodeId
nId
))
getNodePhylo
::
NodeId
->
Cmd
err
(
Node
HyperdataPhylo
)
getNodePhylo
::
HasNodeError
err
=>
NodeId
->
Cmd
err
(
Node
HyperdataPhylo
)
getNodePhylo
nId
=
do
fromMaybe
(
error
$
"Node Phylo does not exist: "
<>
show
nId
)
.
headMay
<$>
runOpaQuery
(
limit
1
$
selectNode
(
pgNodeId
nId
))
res
<-
headMay
<$>
runOpaQuery
(
selectNode
(
pgNodeId
nId
))
case
res
of
Nothing
->
nodeError
(
DoesNotExist
nId
)
Just
r
->
pure
r
getNodesWithType
::
Column
PGInt4
->
Cmd
err
[
Node
HyperdataDocument
]
getNodesWithType
=
runOpaQuery
.
selectNodesWithType
...
...
@@ -293,13 +296,18 @@ nodePhyloW maybeName maybePhylo pId = node NodePhylo name graph (Just pId)
name
=
maybe
"Phylo"
identity
maybeName
graph
=
maybe
arbitraryPhylo
identity
maybePhylo
------------------------------------------------------------------------
arbitraryDashboard
::
HyperdataDashboard
arbitraryDashboard
=
HyperdataDashboard
(
Just
"Preferences"
)
[]
------------------------------------------------------------------------
node
::
(
ToJSON
a
,
Hyperdata
a
)
=>
NodeType
->
Name
->
a
->
Maybe
ParentId
->
UserId
->
NodeWrite
node
::
(
ToJSON
a
,
Hyperdata
a
)
=>
NodeType
->
Name
->
a
->
Maybe
ParentId
->
UserId
->
NodeWrite
node
nodeType
name
hyperData
parentId
userId
=
Node
Nothing
(
pgInt4
typeId
)
...
...
@@ -355,7 +363,8 @@ data Node' = Node' { _n_type :: NodeType
}
deriving
(
Show
)
mkNodes
::
[
NodeWrite
]
->
Cmd
err
Int64
mkNodes
ns
=
mkCmd
$
\
conn
->
runInsert_
conn
$
Insert
nodeTable
ns
rCount
Nothing
mkNodes
ns
=
mkCmd
$
\
conn
->
runInsert_
conn
$
Insert
nodeTable
ns
rCount
Nothing
mkNodeR
::
[
NodeWrite
]
->
Cmd
err
[
NodeId
]
mkNodeR
ns
=
mkCmd
$
\
conn
->
runInsert_
conn
$
Insert
nodeTable
ns
(
rReturning
_node_id
)
Nothing
...
...
@@ -365,7 +374,11 @@ mkNodeR ns = mkCmd $ \conn -> runInsert_ conn $ Insert nodeTable ns (rReturning
data
NewNode
=
NewNode
{
_newNodeId
::
NodeId
,
_newNodeChildren
::
[
NodeId
]
}
postNode
::
HasNodeError
err
=>
UserId
->
Maybe
ParentId
->
Node'
->
Cmd
err
NewNode
postNode
::
HasNodeError
err
=>
UserId
->
Maybe
ParentId
->
Node'
->
Cmd
err
NewNode
postNode
uid
pid
(
Node'
nt
txt
v
[]
)
=
do
pids
<-
mkNodeR
[
node2table
uid
pid
(
Node'
nt
txt
v
[]
)]
...
...
src/Gargantext/Database/Query/Table/Node/Error.hs
View file @
1b07704e
...
...
@@ -26,6 +26,7 @@ Portability : POSIX
module
Gargantext.Database.Query.Table.Node.Error
where
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Control.Lens
(
Prism
'
,
(
#
),
(
^?
))
import
Control.Monad.Error.Class
(
MonadError
(
..
))
import
Gargantext.Prelude
hiding
(
sum
,
head
)
...
...
@@ -43,6 +44,7 @@ data NodeError = NoListFound
|
NegativeId
|
NotImplYet
|
ManyNodeUsers
|
DoesNotExist
NodeId
instance
Show
NodeError
where
...
...
@@ -58,6 +60,7 @@ instance Show NodeError
show
NotImplYet
=
"Not implemented yet"
show
ManyParents
=
"Too many parents"
show
ManyNodeUsers
=
"Many userNode/user"
show
(
DoesNotExist
n
)
=
"Node does not exist"
<>
show
n
class
HasNodeError
e
where
_NodeError
::
Prism'
e
NodeError
...
...
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