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
4097d4fe
Commit
4097d4fe
authored
Dec 04, 2019
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[API] attempt to implement node count in API
parent
7f6848cd
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
20 additions
and
7 deletions
+20
-7
Node.hs
src/Gargantext/API/Node.hs
+3
-1
Types.hs
src/Gargantext/Core/Types.hs
+6
-0
Children.hs
src/Gargantext/Database/Node/Children.hs
+11
-6
No files found.
src/Gargantext/API/Node.hs
View file @
4097d4fe
...
...
@@ -55,6 +55,7 @@ import Gargantext.API.Ngrams.NTree (MyTree)
import
Gargantext.API.Search
(
SearchDocsAPI
,
searchDocs
)
import
Gargantext.API.Table
import
Gargantext.API.Types
import
Gargantext.Core.Types
(
NodeTableResult
(
..
))
import
Gargantext.Core.Types.Main
(
Tree
,
NodeTree
,
ListType
)
import
Gargantext.Database.Config
(
nodeTypeId
)
import
Gargantext.Database.Facet
(
FacetDoc
,
OrderBy
(
..
))
...
...
@@ -158,7 +159,8 @@ type ChildrenApi a = Summary " Summary children"
:>
QueryParam
"type"
NodeType
:>
QueryParam
"offset"
Int
:>
QueryParam
"limit"
Int
:>
Get
'[
J
SON
]
[
Node
a
]
-- :> Get '[JSON] [Node a]
:>
Get
'[
J
SON
]
(
NodeTableResult
(
Node
a
))
------------------------------------------------------------------------
type
NodeNodeAPI
a
=
Get
'[
J
SON
]
(
Node
a
)
...
...
src/Gargantext/Core/Types.hs
View file @
4097d4fe
...
...
@@ -22,6 +22,7 @@ module Gargantext.Core.Types ( module Gargantext.Core.Types.Main
,
Label
,
Stems
,
HasInvalidError
(
..
),
assertValid
,
Name
,
NodeTableResult
(
..
)
)
where
import
Control.Lens
(
Prism
'
,
(
#
))
...
...
@@ -135,3 +136,8 @@ assertValid :: (MonadError e m, HasInvalidError e) => Validation -> m ()
assertValid
v
=
when
(
not
$
validationIsValid
v
)
$
throwError
$
_InvalidError
#
v
-- assertValid :: MonadIO m => Validation -> m ()
-- assertValid v = when (not $ validationIsValid v) $ fail $ show v
data
NodeTableResult
a
=
NodeTableResult
{
tr_count
::
Int
,
tr_docs
::
[
a
]
}
deriving
(
Generic
)
src/Gargantext/Database/Node/Children.hs
View file @
4097d4fe
...
...
@@ -30,7 +30,6 @@ import Gargantext.Database.Node.Contact (HyperdataContact)
import
Gargantext.Database.Schema.Node
(
pgNodeId
)
import
Control.Arrow
(
returnA
)
getAllDocuments
::
ParentId
->
Cmd
err
[
Node
HyperdataDocument
]
getAllDocuments
pId
=
getAllChildren
pId
(
Proxy
::
Proxy
HyperdataDocument
)
(
Just
NodeDocument
)
...
...
@@ -52,11 +51,17 @@ getChildren :: JSONB a
->
Maybe
NodeType
->
Maybe
Offset
->
Maybe
Limit
->
Cmd
err
[
Node
a
]
getChildren
pId
_
maybeNodeType
maybeOffset
maybeLimit
=
runOpaQuery
$
limit'
maybeLimit
$
offset'
maybeOffset
$
orderBy
(
asc
_node_id
)
$
selectChildren
pId
maybeNodeType
->
Cmd
err
(
NodeTableResult
a
)
getChildren
pId
_
maybeNodeType
maybeOffset
maybeLimit
=
do
docs
<-
runOpaQuery
$
limit'
maybeLimit
$
offset'
maybeOffset
$
orderBy
(
asc
_node_id
)
$
selectChildren
pId
maybeNodeType
allDocs
<-
runOpaQuery
$
limit'
Nothing
$
offset'
Nothing
$
selectChildren
pId
maybeNodeType
pure
$
NodeTableResult
{
tr_docs
=
docs
,
tr_count
=
(
length
allDocs
)
}
selectChildren
::
ParentId
->
Maybe
NodeType
...
...
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