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
35b8b782
Commit
35b8b782
authored
Aug 28, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graph] some screenshot work
parent
357822b0
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
76 additions
and
59 deletions
+76
-59
Prelude.hs
src/Gargantext/API/Prelude.hs
+4
-3
TFICF.hs
src/Gargantext/Text/Metrics/TFICF.hs
+7
-6
Graph.hs
src/Gargantext/Viz/Graph.hs
+7
-6
API.hs
src/Gargantext/Viz/Graph/API.hs
+58
-44
No files found.
src/Gargantext/API/Prelude.hs
View file @
35b8b782
...
@@ -33,6 +33,10 @@ import Crypto.JOSE.Error as Jose
...
@@ -33,6 +33,10 @@ import Crypto.JOSE.Error as Jose
import
Data.Aeson.Types
import
Data.Aeson.Types
import
Data.Typeable
import
Data.Typeable
import
Data.Validity
import
Data.Validity
import
Servant
import
Servant.Job.Async
import
Servant.Job.Core
(
HasServerError
(
..
),
serverError
)
import
Gargantext.API.Admin.Orchestrator.Types
import
Gargantext.API.Admin.Orchestrator.Types
import
Gargantext.API.Admin.Settings
import
Gargantext.API.Admin.Settings
import
Gargantext.API.Ngrams
import
Gargantext.API.Ngrams
...
@@ -41,9 +45,6 @@ import Gargantext.Database.Prelude
...
@@ -41,9 +45,6 @@ import Gargantext.Database.Prelude
import
Gargantext.Database.Query.Table.Node.Error
(
NodeError
(
..
),
HasNodeError
(
..
))
import
Gargantext.Database.Query.Table.Node.Error
(
NodeError
(
..
),
HasNodeError
(
..
))
import
Gargantext.Database.Query.Tree
import
Gargantext.Database.Query.Tree
import
Gargantext.Prelude
import
Gargantext.Prelude
import
Servant
import
Servant.Job.Async
(
HasJobEnv
)
import
Servant.Job.Core
(
HasServerError
(
..
),
serverError
)
class
HasJoseError
e
where
class
HasJoseError
e
where
_JoseError
::
Prism'
e
Jose
.
Error
_JoseError
::
Prism'
e
Jose
.
Error
...
...
src/Gargantext/Text/Metrics/TFICF.hs
View file @
35b8b782
...
@@ -23,13 +23,14 @@ module Gargantext.Text.Metrics.TFICF ( TFICF
...
@@ -23,13 +23,14 @@ module Gargantext.Text.Metrics.TFICF ( TFICF
)
)
where
where
import
Data.Text
(
Text
)
import
qualified
Data.List
as
List
import
Gargantext.Prelude
import
Data.Set
(
Set
)
import
Gargantext.Core.Types
(
Ordering
(
..
))
import
Data.Map.Strict
(
Map
,
toList
)
import
Data.Map.Strict
(
Map
,
toList
)
import
qualified
Data.Ord
as
DO
(
Down
(
..
))
import
qualified
Data.Ord
as
DO
(
Down
(
..
))
import
qualified
Data.List
as
List
import
Data.Set
(
Set
)
import
Data.Text
import
Gargantext.Prelude
import
Gargantext.Core.Types
(
Ordering
(
..
))
path
::
Text
path
::
Text
path
=
"[G.T.Metrics.TFICF]"
path
=
"[G.T.Metrics.TFICF]"
...
@@ -49,7 +50,7 @@ tficf :: TficfContext Count Total
...
@@ -49,7 +50,7 @@ tficf :: TficfContext Count Total
tficf
(
TficfInfra
(
Count
ic
)
(
Total
it
)
)
tficf
(
TficfInfra
(
Count
ic
)
(
Total
it
)
)
(
TficfSupra
(
Count
sc
)
(
Total
st
)
)
(
TficfSupra
(
Count
sc
)
(
Total
st
)
)
|
it
>=
ic
&&
st
>=
sc
&&
it
<=
st
=
(
ic
/
it
)
/
log
(
sc
/
st
)
|
it
>=
ic
&&
st
>=
sc
&&
it
<=
st
=
(
ic
/
it
)
/
log
(
sc
/
st
)
|
otherwise
=
panic
$
"[ERR]"
<>
path
<>
" Frequency impossible"
|
otherwise
=
panic
$
"[ERR]"
<>
path
<>
" Frequency impossible"
tficf
_
_
=
panic
$
"[ERR]"
<>
path
<>
"Undefined for these contexts"
tficf
_
_
=
panic
$
"[ERR]"
<>
path
<>
"Undefined for these contexts"
...
...
src/Gargantext/Viz/Graph.hs
View file @
35b8b782
...
@@ -102,6 +102,7 @@ data GraphMetadata =
...
@@ -102,6 +102,7 @@ data GraphMetadata =
,
_gm_corpusId
::
[
NodeId
]
-- we can map with different corpus
,
_gm_corpusId
::
[
NodeId
]
-- we can map with different corpus
,
_gm_legend
::
[
LegendField
]
-- legend of the Graph
,
_gm_legend
::
[
LegendField
]
-- legend of the Graph
,
_gm_list
::
ListForGraph
,
_gm_list
::
ListForGraph
,
_gm_startForceAtlas
::
Bool
-- , _gm_version :: Int
-- , _gm_version :: Int
}
}
deriving
(
Show
,
Generic
)
deriving
(
Show
,
Generic
)
...
...
src/Gargantext/Viz/Graph/API.hs
View file @
35b8b782
...
@@ -55,8 +55,8 @@ import Gargantext.Viz.Graph.Distances (Distance(..), GraphMetric(..))
...
@@ -55,8 +55,8 @@ import Gargantext.Viz.Graph.Distances (Distance(..), GraphMetric(..))
-- | There is no Delete specific API for Graph since it can be deleted
-- | There is no Delete specific API for Graph since it can be deleted
-- as simple Node.
-- as simple Node.
type
GraphAPI
=
Get
'[
J
SON
]
Graph
type
GraphAPI
=
Get
'[
J
SON
]
Graph
:<|>
"async"
:>
GraphAsyncAPI
:<|>
"gexf"
:>
Get
'[
X
ML
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Graph
)
:<|>
"gexf"
:>
Get
'[
X
ML
]
(
Headers
'[
S
ervant
.
Header
"Content-Disposition"
Text
]
Graph
)
:<|>
GraphAsyncAPI
:<|>
"versions"
:>
GraphVersionsAPI
:<|>
"versions"
:>
GraphVersionsAPI
data
GraphVersions
=
data
GraphVersions
=
...
@@ -70,8 +70,8 @@ instance ToSchema GraphVersions
...
@@ -70,8 +70,8 @@ instance ToSchema GraphVersions
graphAPI
::
UserId
->
NodeId
->
GargServer
GraphAPI
graphAPI
::
UserId
->
NodeId
->
GargServer
GraphAPI
graphAPI
u
n
=
getGraph
u
n
graphAPI
u
n
=
getGraph
u
n
:<|>
getGraphGexf
u
n
:<|>
graphAsync
u
n
:<|>
graphAsync
u
n
:<|>
getGraphGexf
u
n
:<|>
graphVersionsAPI
u
n
:<|>
graphVersionsAPI
u
n
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -90,8 +90,10 @@ getGraph _uId nId = do
...
@@ -90,8 +90,10 @@ getGraph _uId nId = do
case
graph
of
case
graph
of
Nothing
->
do
Nothing
->
do
graph'
<-
computeGraph
cId
Conditional
NgramsTerms
repo
graph'
<-
computeGraph
cId
Conditional
NgramsTerms
repo
_
<-
updateHyperdata
nId
(
HyperdataGraph
$
Just
graph'
)
mt
<-
defaultGraphMetadata
cId
"Title"
repo
pure
$
trace
"[G.V.G.API] Graph empty, computing"
graph'
let
graph''
=
set
graph_metadata
(
Just
mt
)
graph'
_
<-
updateHyperdata
nId
(
HyperdataGraph
$
Just
graph''
)
pure
$
trace
"[G.V.G.API] Graph empty, computing"
graph''
Just
graph'
->
pure
$
trace
"[G.V.G.API] Graph exists, returning"
graph'
Just
graph'
->
pure
$
trace
"[G.V.G.API] Graph exists, returning"
graph'
...
@@ -100,11 +102,8 @@ recomputeGraph :: UserId -> NodeId -> Distance -> GargNoServer Graph
...
@@ -100,11 +102,8 @@ recomputeGraph :: UserId -> NodeId -> Distance -> GargNoServer Graph
recomputeGraph
_uId
nId
d
=
do
recomputeGraph
_uId
nId
d
=
do
nodeGraph
<-
getNodeWith
nId
HyperdataGraph
nodeGraph
<-
getNodeWith
nId
HyperdataGraph
let
graph
=
nodeGraph
^.
node_hyperdata
.
hyperdataGraph
let
graph
=
nodeGraph
^.
node_hyperdata
.
hyperdataGraph
let
listVersion
=
graph
^?
_Just
let
graphMetadata
=
graph
^?
_Just
.
graph_metadata
.
_Just
.
graph_metadata
let
listVersion
=
graph
^?
_Just
.
graph_metadata
.
_Just
.
gm_list
.
lfg_version
.
_Just
.
gm_list
.
lfg_version
repo
<-
getRepo
repo
<-
getRepo
let
v
=
repo
^.
r_version
let
v
=
repo
^.
r_version
...
@@ -115,15 +114,18 @@ recomputeGraph _uId nId d = do
...
@@ -115,15 +114,18 @@ recomputeGraph _uId nId d = do
case
graph
of
case
graph
of
Nothing
->
do
Nothing
->
do
graph'
<-
computeGraph
cId
d
NgramsTerms
repo
graph'
<-
computeGraph
cId
d
NgramsTerms
repo
_
<-
updateHyperdata
nId
(
HyperdataGraph
$
Just
graph'
)
mt
<-
defaultGraphMetadata
cId
"Title"
repo
pure
$
trace
"[G.V.G.API.recomputeGraph] Graph empty, computed"
graph'
let
graph''
=
set
graph_metadata
(
Just
mt
)
graph'
_
<-
updateHyperdata
nId
(
HyperdataGraph
$
Just
graph''
)
pure
$
trace
"[G.V.G.API.recomputeGraph] Graph empty, computed"
graph''
Just
graph'
->
if
listVersion
==
Just
v
Just
graph'
->
if
listVersion
==
Just
v
then
pure
graph'
then
pure
graph'
else
do
else
do
graph''
<-
computeGraph
cId
d
NgramsTerms
repo
graph''
<-
computeGraph
cId
d
NgramsTerms
repo
_
<-
updateHyperdata
nId
(
HyperdataGraph
$
Just
graph''
)
let
graph'''
=
set
graph_metadata
graphMetadata
graph''
pure
$
trace
"[G.V.G.API] Graph exists, recomputing"
graph''
_
<-
updateHyperdata
nId
(
HyperdataGraph
$
Just
graph'''
)
pure
$
trace
"[G.V.G.API] Graph exists, recomputing"
graph'''
-- TODO use Database Monad only here ?
-- TODO use Database Monad only here ?
...
@@ -147,38 +149,50 @@ computeGraph cId d nt repo = do
...
@@ -147,38 +149,50 @@ computeGraph cId d nt repo = do
graph
<-
liftBase
$
cooc2graph
d
0
myCooc
graph
<-
liftBase
$
cooc2graph
d
0
myCooc
pure
graph
defaultGraphMetadata
::
HasNodeError
err
=>
CorpusId
->
Text
->
NgramsRepo
->
Cmd
err
GraphMetadata
defaultGraphMetadata
cId
t
repo
=
do
lId
<-
defaultList
cId
let
metadata
=
GraphMetadata
"Title"
pure
$
GraphMetadata
{
Order1
_gm_title
=
t
[
cId
]
,
_gm_metric
=
Order1
[
LegendField
1
"#FFF"
"Cluster1"
,
_gm_corpusId
=
[
cId
]
,
_gm_legend
=
[
LegendField
1
"#FFF"
"Cluster1"
,
LegendField
2
"#FFF"
"Cluster2"
,
LegendField
2
"#FFF"
"Cluster2"
,
LegendField
3
"#FFF"
"Cluster3"
,
LegendField
3
"#FFF"
"Cluster3"
,
LegendField
4
"#FFF"
"Cluster4"
,
LegendField
4
"#FFF"
"Cluster4"
]
]
(
ListForGraph
lId
(
repo
^.
r_version
))
,
_gm_list
=
(
ListForGraph
lId
(
repo
^.
r_version
))
,
_gm_startForceAtlas
=
True
}
-- (map (\n -> LegendField n "#FFFFFF" (pack $ show n)) [1..10])
-- (map (\n -> LegendField n "#FFFFFF" (pack $ show n)) [1..10])
pure
$
set
graph_metadata
(
Just
metadata
)
graph
------------------------------------------------------------
------------------------------------------------------------
type
GraphAsyncAPI
=
Summary
"
Upda
te graph"
type
GraphAsyncAPI
=
Summary
"
Recompu
te graph"
:>
"async
"
:>
"recompute
"
:>
AsyncJobsAPI
JobLog
()
JobLog
:>
AsyncJobsAPI
JobLog
()
JobLog
graphAsync
::
UserId
->
NodeId
->
GargServer
GraphAsyncAPI
graphAsync
::
UserId
->
NodeId
->
GargServer
GraphAsyncAPI
graphAsync
u
n
=
graphAsync
u
n
=
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
_
log'
->
graph
Async'
u
n
(
liftBase
.
log'
))
JobFunction
(
\
_
log'
->
graph
Recompute
u
n
(
liftBase
.
log'
))
graph
Async'
::
UserId
graph
Recompute
::
UserId
->
NodeId
->
NodeId
->
(
JobLog
->
GargNoServer
()
)
->
(
JobLog
->
GargNoServer
()
)
->
GargNoServer
JobLog
->
GargNoServer
JobLog
graph
Async'
u
n
logStatus
=
do
graph
Recompute
u
n
logStatus
=
do
logStatus
JobLog
{
_scst_succeeded
=
Just
0
logStatus
JobLog
{
_scst_succeeded
=
Just
0
,
_scst_failed
=
Just
0
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
1
,
_scst_remaining
=
Just
1
...
...
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