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
120
Issues
120
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
2fcc7fd7
Commit
2fcc7fd7
authored
Apr 21, 2023
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Tree] Flat tree API for search
parent
d721af08
Pipeline
#3921
failed with stage
in 28 minutes and 38 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
30 additions
and
5 deletions
+30
-5
Node.hs
src/Gargantext/API/Node.hs
+7
-1
Routes.hs
src/Gargantext/API/Routes.hs
+7
-0
Tree.hs
src/Gargantext/Database/Query/Tree.hs
+16
-4
No files found.
src/Gargantext/API/Node.hs
View file @
2fcc7fd7
...
...
@@ -62,7 +62,7 @@ import Gargantext.Database.Query.Table.Node.Update (Update(..), update)
import
Gargantext.Database.Query.Table.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Database.Query.Table.NodeContext
(
nodeContextsCategory
,
nodeContextsScore
)
import
Gargantext.Database.Query.Table.NodeNode
import
Gargantext.Database.Query.Tree
(
tree
,
TreeMode
(
..
))
import
Gargantext.Database.Query.Tree
(
tree
,
tree_flat
,
TreeMode
(
..
))
import
Gargantext.Prelude
import
Servant
import
Test.QuickCheck
(
elements
)
...
...
@@ -336,6 +336,12 @@ treeAPI :: NodeId -> GargServer TreeAPI
treeAPI
id
=
tree
TreeAdvanced
id
:<|>
tree
TreeFirstLevel
id
type
TreeFlatAPI
=
QueryParams
"type"
NodeType
:>
Get
'[
J
SON
]
[
NodeTree
]
treeFlatAPI
::
NodeId
->
GargServer
TreeFlatAPI
treeFlatAPI
=
tree_flat
------------------------------------------------------------------------
-- | TODO Check if the name is less than 255 char
rename
::
NodeId
->
RenameNode
->
Cmd
err
[
Int
]
...
...
src/Gargantext/API/Routes.hs
View file @
2fcc7fd7
...
...
@@ -162,6 +162,10 @@ type GargPrivateAPI' =
:<|>
"tree"
:>
Summary
"Tree endpoint"
:>
Capture
"tree_id"
NodeId
:>
TreeAPI
-- Flat tree endpoint
:<|>
"treeflat"
:>
Summary
"Flat tree endpoint"
:>
Capture
"tree_id"
NodeId
:>
TreeFlatAPI
:<|>
"members"
:>
Summary
"Team node members"
:>
MembersAPI
...
...
@@ -252,6 +256,9 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
:<|>
withAccess
(
Proxy
::
Proxy
TreeAPI
)
Proxy
uid
<$>
PathNode
<*>
treeAPI
:<|>
withAccess
(
Proxy
::
Proxy
TreeFlatAPI
)
Proxy
uid
<$>
PathNode
<*>
treeFlatAPI
:<|>
members
uid
-- TODO access
:<|>
addCorpusWithForm
(
RootId
(
NodeId
uid
))
...
...
src/Gargantext/Database/Query/Tree.hs
View file @
2fcc7fd7
...
...
@@ -22,6 +22,7 @@ module Gargantext.Database.Query.Tree
,
isDescendantOf
,
isIn
,
tree
,
tree_flat
,
TreeMode
(
..
)
,
findNodesId
,
DbTreeNode
(
..
)
...
...
@@ -95,7 +96,6 @@ tree TreeFirstLevel = tree_first_level
-- (without shared folders)
-- keeping this for teaching purpose only
tree_basic
::
(
HasTreeError
err
,
HasNodeError
err
)
=>
RootId
->
[
NodeType
]
->
Cmd
err
(
Tree
NodeTree
)
...
...
@@ -144,6 +144,18 @@ tree_first_level r nodeTypes = do
-- printDebug (rPrefix "tree") ret
pure
ret
-- | Fetch tree in a flattened form
tree_flat
::
(
HasTreeError
err
,
HasNodeError
err
)
=>
RootId
->
[
NodeType
]
->
Cmd
err
[
NodeTree
]
tree_flat
r
nodeTypes
=
do
mainRoot
<-
findNodes
r
Private
nodeTypes
publicRoots
<-
findNodes
r
PublicDirect
nodeTypes
sharedRoots
<-
findNodes
r
SharedDirect
nodeTypes
pure
$
map
toNodeTree
(
mainRoot
<>
sharedRoots
<>
publicRoots
)
------------------------------------------------------------------------
data
NodeMode
=
Private
|
Shared
|
Public
|
SharedDirect
|
PublicDirect
...
...
@@ -263,9 +275,9 @@ toTree m =
-- m' ^.. at (Just $ _dt_nodeId root) . _Just . each . to (toTree' m')
toListOf
(
at
(
Just
$
_dt_nodeId
root
)
.
_Just
.
each
.
to
(
toTree'
m'
))
m'
toNodeTree
::
DbTreeNode
->
NodeTree
toNodeTree
(
DbTreeNode
nId
tId
_
n
)
=
NodeTree
n
(
fromNodeTypeId
tId
)
nId
toNodeTree
::
DbTreeNode
->
NodeTree
toNodeTree
(
DbTreeNode
nId
tId
_
n
)
=
NodeTree
n
(
fromNodeTypeId
tId
)
nId
------------------------------------------------------------------------
toTreeParent
::
[
DbTreeNode
]
...
...
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