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
141
Issues
141
List
Board
Labels
Milestones
Merge Requests
5
Merge Requests
5
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
c6cff3e0
Commit
c6cff3e0
authored
May 20, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CLEAN] Graph API
parent
ad208ffc
Pipeline
#858
failed with stage
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
35 deletions
+20
-35
API.hs
src/Gargantext/Viz/Graph/API.hs
+20
-35
No files found.
src/Gargantext/Viz/Graph/API.hs
View file @
c6cff3e0
...
...
@@ -83,35 +83,20 @@ getGraph :: UserId -> NodeId -> GargNoServer Graph
getGraph
_uId
nId
=
do
nodeGraph
<-
getNodeWith
nId
HyperdataGraph
let
graph
=
nodeGraph
^.
node_hyperdata
.
hyperdataGraph
-- let listVersion = graph ^? _Just
-- . graph_metadata
-- . _Just
-- . gm_list
-- . lfg_version
repo
<-
getRepo
-- let v = repo ^. r_version
-- nodeUser <- getNodeUser (NodeId uId)
-- let uId' = nodeUser ^. node_userId
let
cId
=
maybe
(
panic
"[
ERR:
G.V.G.API] Node has no parent"
)
let
cId
=
maybe
(
panic
"[G.V.G.API] Node has no parent"
)
identity
$
nodeGraph
^.
node_parentId
g
<-
case
graph
of
Nothing
->
do
graph'
<-
computeGraph
cId
NgramsTerms
repo
_
<-
updateHyperdata
nId
(
HyperdataGraph
$
Just
graph'
)
pure
$
trace
"Graph empty, computing"
$
graph'
_
<-
updateHyperdata
nId
(
HyperdataGraph
$
Just
graph'
)
pure
$
trace
"
[G.V.G.API]
Graph empty, computing"
$
graph'
Just
graph'
->
pure
$
trace
"Graph exists, returning"
$
graph'
Just
graph'
->
pure
$
trace
"
[G.V.G.API]
Graph exists, returning"
$
graph'
-- Just graph' -> if listVersion == Just v
-- then pure graph'
-- else do
-- graph'' <- computeGraph cId NgramsTerms repo
-- _ <- updateHyperdata nId (HyperdataGraph $ Just graph'')
-- pure graph''
pure
g
...
...
@@ -126,12 +111,8 @@ recomputeGraph _uId nId = do
.
lfg_version
repo
<-
getRepo
let
v
=
repo
^.
r_version
-- nodeUser <- getNodeUser (NodeId uId)
-- let uId' = nodeUser ^. node_userId
let
cId
=
maybe
(
panic
"[ERR:G.V.G.API] Node has no parent"
)
let
v
=
repo
^.
r_version
let
cId
=
maybe
(
panic
"[G.V.G.API.recomputeGraph] Node has no parent"
)
identity
$
nodeGraph
^.
node_parentId
...
...
@@ -139,14 +120,14 @@ recomputeGraph _uId nId = do
Nothing
->
do
graph'
<-
computeGraph
cId
NgramsTerms
repo
_
<-
updateHyperdata
nId
(
HyperdataGraph
$
Just
graph'
)
pure
$
trace
"[recomputeGraph] Graph empty, computed"
$
graph'
pure
$
trace
"[
G.V.G.API.
recomputeGraph] Graph empty, computed"
$
graph'
Just
graph'
->
if
listVersion
==
Just
v
then
pure
graph'
else
do
graph''
<-
computeGraph
cId
NgramsTerms
repo
_
<-
updateHyperdata
nId
(
HyperdataGraph
$
Just
graph''
)
pure
$
trace
"[
recomputeGraph
] Graph exists, recomputing"
$
graph''
pure
$
trace
"[
G.V.G.API
] Graph exists, recomputing"
$
graph''
pure
g
...
...
@@ -178,18 +159,12 @@ computeGraph cId nt repo = do
let
graph'
=
set
graph_metadata
(
Just
metadata
)
graph
pure
graph'
------------------------------------------------------------
getGraphGexf
::
UserId
->
NodeId
->
GargNoServer
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Graph
)
getGraphGexf
uId
nId
=
do
graph
<-
getGraph
uId
nId
pure
$
addHeader
(
concat
[
"attachment; filename=graph.gexf"
])
graph
------------------------------------------------------------
type
GraphAsyncAPI
=
Summary
"Update graph"
:>
"async"
:>
AsyncJobsAPI
ScraperStatus
()
ScraperStatus
graphAsync
::
UserId
->
NodeId
->
GargServer
GraphAsyncAPI
graphAsync
u
n
=
serveJobsAPI
$
...
...
@@ -214,7 +189,6 @@ graphAsync' u n logStatus = do
}
------------------------------------------------------------
type
GraphVersionsAPI
=
Summary
"Graph versions"
:>
Get
'[
J
SON
]
GraphVersions
:<|>
Summary
"Recompute graph version"
...
...
@@ -243,3 +217,14 @@ graphVersions _uId nId = do
recomputeVersions
::
UserId
->
NodeId
->
GargNoServer
Graph
recomputeVersions
uId
nId
=
recomputeGraph
uId
nId
------------------------------------------------------------
getGraphGexf
::
UserId
->
NodeId
->
GargNoServer
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Graph
)
getGraphGexf
uId
nId
=
do
graph
<-
getGraph
uId
nId
pure
$
addHeader
(
concat
[
"attachment; filename=graph.gexf"
])
graph
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