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
00960e3a
Commit
00960e3a
authored
Oct 04, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[write nodes] use closest corpus as parent
parent
7647ad93
Pipeline
#1923
canceled with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
28 additions
and
10 deletions
+28
-10
DocumentsFromWriteNodes.hs
src/Gargantext/API/Node/DocumentsFromWriteNodes.hs
+5
-10
Node.hs
src/Gargantext/Database/Query/Table/Node.hs
+23
-0
No files found.
src/Gargantext/API/Node/DocumentsFromWriteNodes.hs
View file @
00960e3a
...
...
@@ -34,7 +34,7 @@ import Gargantext.Database.Action.Flow.Types (FlowCmdM)
import
Gargantext.Database.Admin.Types.Hyperdata.Document
(
HyperdataDocument
(
..
))
import
Gargantext.Database.Admin.Types.Hyperdata.Frame
import
Gargantext.Database.Admin.Types.Node
import
Gargantext.Database.Query.Table.Node
(
getChildrenByType
,
getNodeWith
)
import
Gargantext.Database.Query.Table.Node
(
getChildrenByType
,
get
ClosestParentIdByType'
,
get
NodeWith
)
import
Gargantext.Database.Schema.Node
(
node_hyperdata
)
import
Gargantext.Prelude
import
GHC.Generics
(
Generic
)
...
...
@@ -60,7 +60,6 @@ api uId nId =
JobFunction
(
\
p
log''
->
let
log'
x
=
do
printDebug
"documents from write nodes"
x
liftBase
$
log''
x
in
documentsFromWriteNodes
uId
nId
p
(
liftBase
.
log'
)
)
...
...
@@ -71,7 +70,7 @@ documentsFromWriteNodes :: (HasSettings env, FlowCmdM env err m)
->
Params
->
(
JobLog
->
m
()
)
->
m
JobLog
documentsFromWriteNodes
uId
nId
p
logStatus
=
do
documentsFromWriteNodes
uId
nId
_
p
logStatus
=
do
logStatus
JobLog
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
...
...
@@ -79,12 +78,10 @@ documentsFromWriteNodes uId nId p logStatus = do
,
_scst_events
=
Just
[]
}
_
<-
printDebug
"[documentsFromWriteNodes] inside job, uId"
uId
_
<-
printDebug
"[documentsFromWriteNodes] inside job, nId"
nId
_
<-
printDebug
"[documentsFromWriteNodes] inside job, p"
p
mcId
<-
getClosestParentIdByType'
nId
NodeCorpus
let
cId
=
maybe
(
panic
"[G.A.N.DFWN] Node has no parent"
)
identity
mcId
frameWriteIds
<-
getChildrenByType
nId
NodeFrameWrite
_
<-
printDebug
"[documentsFromWriteNodes] children"
frameWriteIds
-- https://write.frame.gargantext.org/<frame_id>/download
frameWrites
<-
mapM
(
\
id
->
getNodeWith
id
(
Proxy
::
Proxy
HyperdataFrame
))
frameWriteIds
...
...
@@ -94,13 +91,11 @@ documentsFromWriteNodes uId nId p logStatus = do
contents
<-
getHyperdataFrameContents
(
node
^.
node_hyperdata
)
pure
(
node
,
contents
)
)
frameWrites
_
<-
printDebug
"[documentsFromWriteNodes] frameWritesWithContents"
frameWritesWithContents
let
parsedE
=
(
\
(
node
,
contents
)
->
hyperdataDocumentFromFrameWrite
(
node
^.
node_hyperdata
,
contents
))
<$>
frameWritesWithContents
let
parsed
=
rights
parsedE
_
<-
printDebug
"[documentsFromWriteNodes] parsed"
parsed
_
<-
flowDataText
(
RootId
(
NodeId
uId
))
(
DataNew
[
parsed
])
(
Multi
EN
)
n
Id
Nothing
_
<-
flowDataText
(
RootId
(
NodeId
uId
))
(
DataNew
[
parsed
])
(
Multi
EN
)
c
Id
Nothing
pure
JobLog
{
_scst_succeeded
=
Just
2
,
_scst_failed
=
Just
0
...
...
src/Gargantext/Database/Query/Table/Node.hs
View file @
00960e3a
...
...
@@ -142,6 +142,29 @@ getClosestParentIdByType nId nType = do
WHERE n1.id = ? AND 0 = ?;
|]
-- | Similar to `getClosestParentIdByType` but includes current node
-- in search too
getClosestParentIdByType'
::
HasDBid
NodeType
=>
NodeId
->
NodeType
->
Cmd
err
(
Maybe
NodeId
)
getClosestParentIdByType'
nId
nType
=
do
result
<-
runPGSQuery
query
(
nId
,
0
::
Int
)
case
result
of
[(
NodeId
id
,
pTypename
)]
->
do
if
toDBid
nType
==
pTypename
then
pure
$
Just
$
NodeId
id
else
getClosestParentIdByType
nId
nType
_
->
pure
Nothing
where
query
::
DPS
.
Query
query
=
[
sql
|
SELECT n.id, n.typename
FROM nodes n
WHERE n.id = ? AND 0 = ?;
|]
-- | Given a node id, find all it's children (no matter how deep) of
-- given node type.
getChildrenByType
::
HasDBid
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