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
141
Issues
141
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
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
4bf375dd
Commit
4bf375dd
authored
Apr 30, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[DB/REFACT] getNodeWith Proxy
parent
ed7965e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
22 deletions
+17
-22
Node.hs
src/Gargantext/Database/Query/Table/Node.hs
+14
-20
API.hs
src/Gargantext/Viz/Phylo/API.hs
+3
-2
No files found.
src/Gargantext/Database/Query/Table/Node.hs
View file @
4bf375dd
...
...
@@ -31,7 +31,8 @@ module Gargantext.Database.Query.Table.Node
import
Control.Arrow
(
returnA
)
import
Control.Lens
(
set
,
view
)
import
Data.Aeson
import
Data.Maybe
(
Maybe
(
..
),
fromMaybe
)
import
Data.Proxy
(
Proxy
(
..
))
import
Data.Maybe
(
Maybe
(
..
))
import
Data.Text
(
Text
)
import
GHC.Int
(
Int64
)
import
Gargantext.Core.Types
...
...
@@ -144,27 +145,20 @@ selectNodesWithType type_id = proc () -> do
type
JSONB
=
QueryRunnerColumnDefault
PGJsonb
getNode
::
NodeId
->
Cmd
err
(
Node
Value
)
getNode
nId
=
fromMaybe
(
error
$
"Node does not exist: "
<>
show
nId
)
.
headMay
<$>
runOpaQuery
(
limit
1
$
selectNode
(
pgNodeId
nId
))
getNode
::
HasNodeError
err
=>
NodeId
->
Cmd
err
(
Node
Value
)
getNode
nId
=
do
maybeNode
<-
headMay
<$>
runOpaQuery
(
selectNode
(
pgNodeId
nId
))
case
maybeNode
of
Nothing
->
nodeError
(
DoesNotExist
nId
)
Just
r
->
pure
r
getNodeWith
::
JSONB
a
=>
NodeId
->
proxy
a
->
Cmd
err
(
Node
a
)
getNodeWith
::
(
HasNodeError
err
,
JSONB
a
)
=>
NodeId
->
proxy
a
->
Cmd
err
(
Node
a
)
getNodeWith
nId
_
=
do
fromMaybe
(
error
$
"Node does not exist: "
<>
show
nId
)
.
headMay
<$>
runOpaQuery
(
limit
1
$
selectNode
(
pgNodeId
nId
))
getNodePhylo
::
HasNodeError
err
=>
NodeId
->
Cmd
err
(
Node
HyperdataPhylo
)
getNodePhylo
nId
=
do
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
maybeNode
<-
headMay
<$>
runOpaQuery
(
selectNode
(
pgNodeId
nId
))
case
maybeNode
of
Nothing
->
nodeError
(
DoesNotExist
nId
)
Just
r
->
pure
r
------------------------------------------------------------------------
nodeContactW
::
Maybe
Name
->
Maybe
HyperdataContact
...
...
src/Gargantext/Viz/Phylo/API.hs
View file @
4bf375dd
...
...
@@ -28,10 +28,11 @@ import Data.String.Conversions
--import Control.Monad.Reader (ask)
import
qualified
Data.ByteString
as
DB
import
qualified
Data.ByteString.Lazy
as
DBL
import
Data.Proxy
(
Proxy
(
..
))
import
Data.Swagger
import
Gargantext.API.Admin.Types
import
Gargantext.Database.Schema.Node
(
_node_hyperdata
)
import
Gargantext.Database.Query.Table.Node
(
insertNodes
,
nodePhyloW
,
getNode
Phylo
)
import
Gargantext.Database.Query.Table.Node
(
insertNodes
,
nodePhyloW
,
getNode
With
)
import
Gargantext.Database.Admin.Types.Node
-- (PhyloId, ListId, CorpusId, UserId, NodeId(..))
import
Gargantext.Prelude
import
Gargantext.Viz.Phylo
...
...
@@ -101,7 +102,7 @@ type GetPhylo = QueryParam "listId" ListId
getPhylo
::
PhyloId
->
GargServer
GetPhylo
--getPhylo phId _lId l msb _f _b _l' _ms _x _y _z _ts _s _o _e _d _b' = do
getPhylo
phId
_lId
l
msb
=
do
phNode
<-
getNode
Phylo
phId
phNode
<-
getNode
With
phId
(
Proxy
::
Proxy
HyperdataPhylo
)
let
level
=
maybe
2
identity
l
branc
=
maybe
2
identity
msb
...
...
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