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
197
Issues
197
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
12232f3a
Commit
12232f3a
authored
Aug 29, 2023
by
Fabien Manière
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
new recursiveParents function to get all parents from a node ID to the root element
parent
03bd0bf6
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
22 additions
and
0 deletions
+22
-0
Tree.hs
src/Gargantext/Database/Query/Tree.hs
+22
-0
No files found.
src/Gargantext/Database/Query/Tree.hs
View file @
12232f3a
...
@@ -37,6 +37,7 @@ module Gargantext.Database.Query.Tree
...
@@ -37,6 +37,7 @@ module Gargantext.Database.Query.Tree
,
sharedTreeUpdate
,
sharedTreeUpdate
,
dbTree
,
dbTree
,
updateTree
,
updateTree
,
recursiveParents
)
)
where
where
...
@@ -389,4 +390,25 @@ isIn cId docId = ( == [Only True])
...
@@ -389,4 +390,25 @@ isIn cId docId = ( == [Only True])
WHERE nn.node1_id = ?
WHERE nn.node1_id = ?
AND nn.node2_id = ?;
AND nn.node2_id = ?;
|]
(
cId
,
docId
)
|]
(
cId
,
docId
)
recursiveParents
::
NodeId
->
[
NodeType
]
->
Cmd
err
[
DbTreeNode
]
recursiveParents
nodeId
nodeTypes
=
map
(
\
(
nId
,
tId
,
pId
,
n
)
->
DbTreeNode
nId
tId
pId
n
)
<$>
runPGSQuery
[
sql
|
WITH RECURSIVE recursiveParents AS(
SELECT id, typename, parent_id, name
FROM public.nodes WHERE id = ?
UNION ALL
SELECT n.id, n.typename, n.parent_id, n.name
FROM public.nodes n
INNER JOIN recursiveParents rp ON n.id = rp.parent_id
WHERE n.typename IN ?
) SELECT * FROM recursiveParents;
|]
(
nodeId
,
In
typename
)
where
typename
=
map
nodeTypeId
ns
ns
=
case
nodeTypes
of
[]
->
allNodeTypes
_
->
nodeTypes
-----------------------------------------------------
-----------------------------------------------------
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