Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Przemyslaw Kaminski
haskell-gargantext
Commits
5b92dcdf
Commit
5b92dcdf
authored
Jan 07, 2020
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Unfinished refactoring
parent
93098b80
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
16 additions
and
12 deletions
+16
-12
API.hs
src/Gargantext/Viz/Graph/API.hs
+16
-12
No files found.
src/Gargantext/Viz/Graph/API.hs
View file @
5b92dcdf
...
...
@@ -28,7 +28,7 @@ import Debug.Trace (trace)
import
Control.Lens
(
set
,
(
^.
),
_Just
,
(
^?
))
import
Control.Monad.IO.Class
(
liftIO
)
import
Data.Maybe
(
Maybe
(
..
))
import
Gargantext.API.Ngrams
(
currentV
ersion
)
import
Gargantext.API.Ngrams
(
NgramsRepo
,
r_v
ersion
)
import
Gargantext.API.Ngrams.Tools
import
Gargantext.API.Types
import
Gargantext.Core.Types.Main
...
...
@@ -36,9 +36,10 @@ import Gargantext.Database.Config
import
Gargantext.Database.Metrics.NgramsByNode
(
getNodesByNgramsOnlyUser
)
import
Gargantext.Database.Schema.Ngrams
import
Gargantext.Database.Node.Select
import
Gargantext.Database.Schema.Node
(
getNodeWith
,
defaultList
,
insertGraph
)
import
Gargantext.Database.Schema.Node
(
getNodeWith
,
defaultList
,
insertGraph
,
HasNodeError
)
import
Gargantext.Database.Types.Node
hiding
(
node_id
)
-- (GraphId, ListId, CorpusId, NodeId)
import
Gargantext.Database.Node.UpdateOpaleye
(
updateHyperdata
)
import
Gargantext.Database.Utils
(
Cmd
)
import
Gargantext.Prelude
import
Gargantext.Viz.Graph
import
Gargantext.Viz.Graph.Tools
-- (cooc2graph)
...
...
@@ -70,7 +71,8 @@ getGraph uId nId = do
.
_Just
.
gm_version
v
<-
currentVersion
repo
<-
getRepo
let
v
=
repo
^.
r_version
nodeUser
<-
getNodeWith
(
NodeId
uId
)
HyperdataUser
let
uId'
=
nodeUser
^.
node_userId
...
...
@@ -78,39 +80,41 @@ getGraph uId nId = do
let
cId
=
maybe
(
panic
"[ERR:G.V.G.API] Node has no parent"
)
identity
$
nodeGraph
^.
node_parentId
g
<-
case
graph
of
Nothing
->
do
graph'
<-
computeGraph
cId
NgramsTerms
v
graph'
<-
computeGraph
cId
NgramsTerms
repo
_
<-
insertGraph
cId
uId'
(
HyperdataGraph
$
Just
graph'
)
pure
graph'
Just
graph'
->
if
graphVersion
==
Just
v
then
pure
graph'
else
do
graph''
<-
computeGraph
cId
NgramsTerms
v
graph''
<-
computeGraph
cId
NgramsTerms
repo
_
<-
updateHyperdata
nId
(
HyperdataGraph
$
Just
graph''
)
pure
graph''
pure
$
trace
(
"salut"
<>
show
g
)
$
g
-- TODO use Database Monad only here ?
computeGraph
::
CorpusId
->
NgramsType
->
Int
->
GargServer
(
Get
'[
J
SON
]
Graph
)
computeGraph
cId
nt
v
=
do
computeGraph
::
HasNodeError
err
=>
CorpusId
->
NgramsType
->
NgramsRepo
->
Cmd
err
Graph
computeGraph
cId
nt
repo
=
do
lId
<-
defaultList
cId
v'
<-
currentVersion
-- what is the relation between this version and repo^.r_version.
-- v' <- currentVersion
let
v'
=
repo
^.
r_version
let
metadata
=
GraphMetadata
"Title"
[
cId
]
[
LegendField
1
"#FFF"
"Cluster"
,
LegendField
2
"#FFF"
"Cluster"
]
(
ListForGraph
lId
v'
)
v
(
repo
^.
r_version
)
-- (map (\n -> LegendField n "#FFFFFF" (pack $ show n)) [1..10])
lIds
<-
selectNodesWithUsername
NodeList
userMaster
repo
<-
getRepo
let
ngs
=
filterListWithRoot
GraphTerm
<$>
mapTermListRoot
[
lId
]
nt
repo
let
ngs
=
filterListWithRoot
GraphTerm
$
mapTermListRoot
[
lId
]
nt
repo
myCooc
<-
Map
.
filter
(
>
1
)
<$>
getCoocByNgrams
(
Diagonal
True
)
...
...
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