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
153
Issues
153
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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)
...
@@ -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.Document
(
HyperdataDocument
(
..
))
import
Gargantext.Database.Admin.Types.Hyperdata.Frame
import
Gargantext.Database.Admin.Types.Hyperdata.Frame
import
Gargantext.Database.Admin.Types.Node
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.Database.Schema.Node
(
node_hyperdata
)
import
Gargantext.Prelude
import
Gargantext.Prelude
import
GHC.Generics
(
Generic
)
import
GHC.Generics
(
Generic
)
...
@@ -60,7 +60,6 @@ api uId nId =
...
@@ -60,7 +60,6 @@ api uId nId =
JobFunction
(
\
p
log''
->
JobFunction
(
\
p
log''
->
let
let
log'
x
=
do
log'
x
=
do
printDebug
"documents from write nodes"
x
liftBase
$
log''
x
liftBase
$
log''
x
in
documentsFromWriteNodes
uId
nId
p
(
liftBase
.
log'
)
in
documentsFromWriteNodes
uId
nId
p
(
liftBase
.
log'
)
)
)
...
@@ -71,7 +70,7 @@ documentsFromWriteNodes :: (HasSettings env, FlowCmdM env err m)
...
@@ -71,7 +70,7 @@ documentsFromWriteNodes :: (HasSettings env, FlowCmdM env err m)
->
Params
->
Params
->
(
JobLog
->
m
()
)
->
(
JobLog
->
m
()
)
->
m
JobLog
->
m
JobLog
documentsFromWriteNodes
uId
nId
p
logStatus
=
do
documentsFromWriteNodes
uId
nId
_
p
logStatus
=
do
logStatus
JobLog
{
_scst_succeeded
=
Just
1
logStatus
JobLog
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
,
_scst_failed
=
Just
0
...
@@ -79,12 +78,10 @@ documentsFromWriteNodes uId nId p logStatus = do
...
@@ -79,12 +78,10 @@ documentsFromWriteNodes uId nId p logStatus = do
,
_scst_events
=
Just
[]
,
_scst_events
=
Just
[]
}
}
_
<-
printDebug
"[documentsFromWriteNodes] inside job, uId"
uId
mcId
<-
getClosestParentIdByType'
nId
NodeCorpus
_
<-
printDebug
"[documentsFromWriteNodes] inside job, nId"
nId
let
cId
=
maybe
(
panic
"[G.A.N.DFWN] Node has no parent"
)
identity
mcId
_
<-
printDebug
"[documentsFromWriteNodes] inside job, p"
p
frameWriteIds
<-
getChildrenByType
nId
NodeFrameWrite
frameWriteIds
<-
getChildrenByType
nId
NodeFrameWrite
_
<-
printDebug
"[documentsFromWriteNodes] children"
frameWriteIds
-- https://write.frame.gargantext.org/<frame_id>/download
-- https://write.frame.gargantext.org/<frame_id>/download
frameWrites
<-
mapM
(
\
id
->
getNodeWith
id
(
Proxy
::
Proxy
HyperdataFrame
))
frameWriteIds
frameWrites
<-
mapM
(
\
id
->
getNodeWith
id
(
Proxy
::
Proxy
HyperdataFrame
))
frameWriteIds
...
@@ -94,13 +91,11 @@ documentsFromWriteNodes uId nId p logStatus = do
...
@@ -94,13 +91,11 @@ documentsFromWriteNodes uId nId p logStatus = do
contents
<-
getHyperdataFrameContents
(
node
^.
node_hyperdata
)
contents
<-
getHyperdataFrameContents
(
node
^.
node_hyperdata
)
pure
(
node
,
contents
)
pure
(
node
,
contents
)
)
frameWrites
)
frameWrites
_
<-
printDebug
"[documentsFromWriteNodes] frameWritesWithContents"
frameWritesWithContents
let
parsedE
=
(
\
(
node
,
contents
)
->
hyperdataDocumentFromFrameWrite
(
node
^.
node_hyperdata
,
contents
))
<$>
frameWritesWithContents
let
parsedE
=
(
\
(
node
,
contents
)
->
hyperdataDocumentFromFrameWrite
(
node
^.
node_hyperdata
,
contents
))
<$>
frameWritesWithContents
let
parsed
=
rights
parsedE
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
pure
JobLog
{
_scst_succeeded
=
Just
2
,
_scst_failed
=
Just
0
,
_scst_failed
=
Just
0
...
...
src/Gargantext/Database/Query/Table/Node.hs
View file @
00960e3a
...
@@ -142,6 +142,29 @@ getClosestParentIdByType nId nType = do
...
@@ -142,6 +142,29 @@ getClosestParentIdByType nId nType = do
WHERE n1.id = ? AND 0 = ?;
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 a node id, find all it's children (no matter how deep) of
-- given node type.
-- given node type.
getChildrenByType
::
HasDBid
NodeType
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