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
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
Julien Moutinho
haskell-gargantext
Commits
d37798c1
Commit
d37798c1
authored
Dec 03, 2020
by
Nicolas Pouillard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP refactoring
parent
83403098
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
56 additions
and
40 deletions
+56
-40
package.yaml
package.yaml
+1
-0
Metrics.hs
src/Gargantext/API/Metrics.hs
+13
-12
Types.hs
src/Gargantext/API/Ngrams/Types.hs
+4
-0
Metrics.hs
src/Gargantext/Core/Text/Metrics.hs
+4
-3
Chart.hs
src/Gargantext/Core/Viz/Chart.hs
+7
-5
Types.hs
src/Gargantext/Core/Viz/Types.hs
+6
-4
Metrics.hs
src/Gargantext/Database/Action/Metrics.hs
+2
-1
Lists.hs
src/Gargantext/Database/Action/Metrics/Lists.hs
+1
-1
List.hs
src/Gargantext/Database/Admin/Types/Hyperdata/List.hs
+12
-10
Metrics.hs
src/Gargantext/Database/Admin/Types/Metrics.hs
+6
-4
No files found.
package.yaml
View file @
d37798c1
...
@@ -150,6 +150,7 @@ library:
...
@@ -150,6 +150,7 @@ library:
-
full-text-search
-
full-text-search
-
fullstop
-
fullstop
-
graphviz
-
graphviz
-
hashable
-
haskell-igraph
-
haskell-igraph
-
hlcm
-
hlcm
-
hsparql
-
hsparql
...
...
src/Gargantext/API/Metrics.hs
View file @
d37798c1
...
@@ -19,7 +19,8 @@ module Gargantext.API.Metrics
...
@@ -19,7 +19,8 @@ module Gargantext.API.Metrics
where
where
import
Control.Lens
import
Control.Lens
import
qualified
Data.Map
as
Map
import
Data.HashMap.Strict
(
HashMap
)
import
qualified
Data.HashMap.Strict
as
HM
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Data.Time
(
UTCTime
)
import
Data.Time
(
UTCTime
)
import
Servant
import
Servant
...
@@ -78,7 +79,7 @@ getScatter cId maybeListId tabType _maybeLimit = do
...
@@ -78,7 +79,7 @@ getScatter cId maybeListId tabType _maybeLimit = do
Nothing
->
defaultList
cId
Nothing
->
defaultList
cId
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
let
HyperdataList
{
_hl_scatter
=
scatterMap
}
=
node
^.
node_hyperdata
let
HyperdataList
{
_hl_scatter
=
scatterMap
}
=
node
^.
node_hyperdata
mChart
=
Map
.
lookup
tabType
scatterMap
mChart
=
HM
.
lookup
tabType
scatterMap
chart
<-
case
mChart
of
chart
<-
case
mChart
of
Just
chart
->
pure
chart
Just
chart
->
pure
chart
...
@@ -111,9 +112,9 @@ updateScatter' cId maybeListId tabType maybeLimit = do
...
@@ -111,9 +112,9 @@ updateScatter' cId maybeListId tabType maybeLimit = do
(
ngs'
,
scores
)
<-
Metrics
.
getMetrics
cId
maybeListId
tabType
maybeLimit
(
ngs'
,
scores
)
<-
Metrics
.
getMetrics
cId
maybeListId
tabType
maybeLimit
let
let
metrics
=
map
(
\
(
Scored
t
s1
s2
)
->
Metric
t
s1
s2
(
listType
t
ngs'
))
metrics
=
f
map
(
\
(
Scored
t
s1
s2
)
->
Metric
t
s1
s2
(
listType
t
ngs'
))
$
map
normalizeLocal
scores
$
f
map
normalizeLocal
scores
listType
t
m
=
maybe
(
panic
errorMsg
)
fst
$
Map
.
lookup
t
m
listType
t
m
=
maybe
(
panic
errorMsg
)
fst
$
HM
.
lookup
t
m
errorMsg
=
"API.Node.metrics: key absent"
errorMsg
=
"API.Node.metrics: key absent"
listId
<-
case
maybeListId
of
listId
<-
case
maybeListId
of
...
@@ -122,7 +123,7 @@ updateScatter' cId maybeListId tabType maybeLimit = do
...
@@ -122,7 +123,7 @@ updateScatter' cId maybeListId tabType maybeLimit = do
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
let
hl
=
node
^.
node_hyperdata
let
hl
=
node
^.
node_hyperdata
scatterMap
=
hl
^.
hl_scatter
scatterMap
=
hl
^.
hl_scatter
_
<-
updateHyperdata
listId
$
hl
{
_hl_scatter
=
Map
.
insert
tabType
(
Metrics
metrics
)
scatterMap
}
_
<-
updateHyperdata
listId
$
hl
{
_hl_scatter
=
HM
.
insert
tabType
(
Metrics
metrics
)
scatterMap
}
pure
$
Metrics
metrics
pure
$
Metrics
metrics
...
@@ -172,7 +173,7 @@ getChart cId _start _end maybeListId tabType = do
...
@@ -172,7 +173,7 @@ getChart cId _start _end maybeListId tabType = do
Nothing
->
defaultList
cId
Nothing
->
defaultList
cId
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
let
chartMap
=
node
^.
node_hyperdata
^.
hl_chart
let
chartMap
=
node
^.
node_hyperdata
^.
hl_chart
mChart
=
Map
.
lookup
tabType
chartMap
mChart
=
HM
.
lookup
tabType
chartMap
chart
<-
case
mChart
of
chart
<-
case
mChart
of
Just
chart
->
pure
chart
Just
chart
->
pure
chart
...
@@ -209,7 +210,7 @@ updateChart' cId maybeListId tabType _maybeLimit = do
...
@@ -209,7 +210,7 @@ updateChart' cId maybeListId tabType _maybeLimit = do
let
hl
=
node
^.
node_hyperdata
let
hl
=
node
^.
node_hyperdata
chartMap
=
hl
^.
hl_chart
chartMap
=
hl
^.
hl_chart
h
<-
histoData
cId
h
<-
histoData
cId
_
<-
updateHyperdata
listId
$
hl
{
_hl_chart
=
Map
.
insert
tabType
(
ChartMetrics
h
)
chartMap
}
_
<-
updateHyperdata
listId
$
hl
{
_hl_chart
=
HM
.
insert
tabType
(
ChartMetrics
h
)
chartMap
}
pure
$
ChartMetrics
h
pure
$
ChartMetrics
h
...
@@ -258,7 +259,7 @@ getPie cId _start _end maybeListId tabType = do
...
@@ -258,7 +259,7 @@ getPie cId _start _end maybeListId tabType = do
Nothing
->
defaultList
cId
Nothing
->
defaultList
cId
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
let
pieMap
=
node
^.
node_hyperdata
^.
hl_pie
let
pieMap
=
node
^.
node_hyperdata
^.
hl_pie
mChart
=
Map
.
lookup
tabType
pieMap
mChart
=
HM
.
lookup
tabType
pieMap
chart
<-
case
mChart
of
chart
<-
case
mChart
of
Just
chart
->
pure
chart
Just
chart
->
pure
chart
...
@@ -296,7 +297,7 @@ updatePie' cId maybeListId tabType _maybeLimit = do
...
@@ -296,7 +297,7 @@ updatePie' cId maybeListId tabType _maybeLimit = do
pieMap
=
hl
^.
hl_pie
pieMap
=
hl
^.
hl_pie
p
<-
chartData
cId
(
ngramsTypeFromTabType
tabType
)
MapTerm
p
<-
chartData
cId
(
ngramsTypeFromTabType
tabType
)
MapTerm
_
<-
updateHyperdata
listId
$
hl
{
_hl_pie
=
Map
.
insert
tabType
(
ChartMetrics
p
)
pieMap
}
_
<-
updateHyperdata
listId
$
hl
{
_hl_pie
=
HM
.
insert
tabType
(
ChartMetrics
p
)
pieMap
}
pure
$
ChartMetrics
p
pure
$
ChartMetrics
p
...
@@ -355,7 +356,7 @@ getTree cId _start _end maybeListId tabType listType = do
...
@@ -355,7 +356,7 @@ getTree cId _start _end maybeListId tabType listType = do
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
let
treeMap
=
node
^.
node_hyperdata
^.
hl_tree
let
treeMap
=
node
^.
node_hyperdata
^.
hl_tree
mChart
=
Map
.
lookup
tabType
treeMap
mChart
=
HM
.
lookup
tabType
treeMap
chart
<-
case
mChart
of
chart
<-
case
mChart
of
Just
chart
->
pure
chart
Just
chart
->
pure
chart
...
@@ -393,7 +394,7 @@ updateTree' cId maybeListId tabType listType = do
...
@@ -393,7 +394,7 @@ updateTree' cId maybeListId tabType listType = do
let
hl
=
node
^.
node_hyperdata
let
hl
=
node
^.
node_hyperdata
treeMap
=
hl
^.
hl_tree
treeMap
=
hl
^.
hl_tree
t
<-
treeData
cId
(
ngramsTypeFromTabType
tabType
)
listType
t
<-
treeData
cId
(
ngramsTypeFromTabType
tabType
)
listType
_
<-
updateHyperdata
listId
$
hl
{
_hl_tree
=
Map
.
insert
tabType
(
ChartMetrics
t
)
treeMap
}
_
<-
updateHyperdata
listId
$
hl
{
_hl_tree
=
HM
.
insert
tabType
(
ChartMetrics
t
)
treeMap
}
pure
$
ChartMetrics
t
pure
$
ChartMetrics
t
...
...
src/Gargantext/API/Ngrams/Types.hs
View file @
d37798c1
...
@@ -19,6 +19,7 @@ import Data.Aeson hiding ((.=))
...
@@ -19,6 +19,7 @@ import Data.Aeson hiding ((.=))
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Either
(
Either
(
..
))
import
Data.Either
(
Either
(
..
))
import
Data.Foldable
import
Data.Foldable
import
Data.Hashable
(
Hashable
)
import
qualified
Data.HashMap.Strict.InsOrd
as
InsOrdHashMap
import
qualified
Data.HashMap.Strict.InsOrd
as
InsOrdHashMap
import
qualified
Data.List
as
List
import
qualified
Data.List
as
List
import
Data.Map.Strict
(
Map
)
import
Data.Map.Strict
(
Map
)
...
@@ -60,6 +61,9 @@ data TabType = Docs | Trash | MoreFav | MoreTrash
...
@@ -60,6 +61,9 @@ data TabType = Docs | Trash | MoreFav | MoreTrash
|
Contacts
|
Contacts
deriving
(
Bounded
,
Enum
,
Eq
,
Generic
,
Ord
,
Show
)
deriving
(
Bounded
,
Enum
,
Eq
,
Generic
,
Ord
,
Show
)
instance
Hashable
TabType
instance
FromHttpApiData
TabType
instance
FromHttpApiData
TabType
where
where
parseUrlPiece
"Docs"
=
pure
Docs
parseUrlPiece
"Docs"
=
pure
Docs
...
...
src/Gargantext/Core/Text/Metrics.hs
View file @
d37798c1
...
@@ -30,19 +30,20 @@ import qualified Data.Array.Accelerate as DAA
...
@@ -30,19 +30,20 @@ import qualified Data.Array.Accelerate as DAA
import
qualified
Data.Array.Accelerate.Interpreter
as
DAA
import
qualified
Data.Array.Accelerate.Interpreter
as
DAA
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
import
qualified
Data.Vector
as
V
import
qualified
Data.Vector.Storable
as
Vec
import
qualified
Data.Vector.Storable
as
Vec
type
MapListSize
=
Int
type
MapListSize
=
Int
type
InclusionSize
=
Int
type
InclusionSize
=
Int
scored
::
Ord
t
=>
Map
(
t
,
t
)
Int
->
[
Scored
t
]
scored
::
Ord
t
=>
Map
(
t
,
t
)
Int
->
V
.
Vector
(
Scored
t
)
scored
=
map2scored
.
(
pcaReduceTo
(
Dimension
2
))
.
scored2map
scored
=
map2scored
.
(
pcaReduceTo
(
Dimension
2
))
.
scored2map
where
where
scored2map
::
Ord
t
=>
Map
(
t
,
t
)
Int
->
Map
t
(
Vec
.
Vector
Double
)
scored2map
::
Ord
t
=>
Map
(
t
,
t
)
Int
->
Map
t
(
Vec
.
Vector
Double
)
scored2map
m
=
Map
.
fromList
$
map
(
\
(
Scored
t
i
s
)
->
(
t
,
Vec
.
fromList
[
i
,
s
]))
$
scored'
m
scored2map
m
=
Map
.
fromList
$
map
(
\
(
Scored
t
i
s
)
->
(
t
,
Vec
.
fromList
[
i
,
s
]))
$
scored'
m
map2scored
::
Ord
t
=>
Map
t
(
Vec
.
Vector
Double
)
->
[
Scored
t
]
map2scored
::
Ord
t
=>
Map
t
(
Vec
.
Vector
Double
)
->
V
.
Vector
(
Scored
t
)
map2scored
=
map
(
\
(
t
,
ds
)
->
Scored
t
(
Vec
.
head
ds
)
(
Vec
.
last
ds
))
.
Map
.
toList
map2scored
=
V
.
map
(
\
(
t
,
ds
)
->
Scored
t
(
Vec
.
head
ds
)
(
Vec
.
last
ds
))
.
V
.
fromList
.
Map
.
toList
-- TODO change type with (x,y)
-- TODO change type with (x,y)
data
Scored
ts
=
Scored
data
Scored
ts
=
Scored
...
...
src/Gargantext/Core/Viz/Chart.hs
View file @
d37798c1
...
@@ -14,11 +14,12 @@ Portability : POSIX
...
@@ -14,11 +14,12 @@ Portability : POSIX
module
Gargantext.Core.Viz.Chart
module
Gargantext.Core.Viz.Chart
where
where
import
Data.List
(
unzip
,
sortOn
)
import
Data.List
(
sortOn
)
import
Data.Map
(
toList
)
import
Data.Map
(
toList
)
import
qualified
Data.List
as
List
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
import
Data.Maybe
(
catMaybes
)
import
Data.Maybe
(
catMaybes
)
import
qualified
Data.Vector
as
V
import
Gargantext.Core.Types.Main
import
Gargantext.Core.Types.Main
import
Gargantext.Database.Admin.Config
import
Gargantext.Database.Admin.Config
...
@@ -42,8 +43,9 @@ import Gargantext.Core.Viz.Types
...
@@ -42,8 +43,9 @@ import Gargantext.Core.Viz.Types
histoData
::
CorpusId
->
Cmd
err
Histo
histoData
::
CorpusId
->
Cmd
err
Histo
histoData
cId
=
do
histoData
cId
=
do
dates
<-
selectDocsDates
cId
dates
<-
selectDocsDates
cId
let
(
ls
,
css
)
=
unzip
let
(
ls
,
css
)
=
V
.
unzip
$
sortOn
fst
$
V
.
fromList
$
sortOn
fst
-- TODO Vector.sortOn
$
toList
$
toList
$
occurrencesWith
identity
dates
$
occurrencesWith
identity
dates
pure
(
Histo
ls
css
)
pure
(
Histo
ls
css
)
...
@@ -65,8 +67,8 @@ chartData cId nt lt = do
...
@@ -65,8 +67,8 @@ chartData cId nt lt = do
(
_total
,
mapTerms
)
<-
countNodesByNgramsWith
(
group
dico
)
(
_total
,
mapTerms
)
<-
countNodesByNgramsWith
(
group
dico
)
<$>
getNodesByNgramsOnlyUser
cId
(
ls'
<>
ls
)
nt
terms
<$>
getNodesByNgramsOnlyUser
cId
(
ls'
<>
ls
)
nt
terms
let
(
dates
,
count
)
=
unzip
$
map
(
\
(
t
,(
d
,
_
))
->
(
t
,
d
))
$
Map
.
toList
mapTerms
let
(
dates
,
count
)
=
V
.
unzip
$
fmap
(
\
(
t
,(
d
,
_
))
->
(
t
,
d
))
$
V
.
fromList
$
Map
.
toList
mapTerms
pure
(
Histo
dates
(
map
round
count
))
pure
(
Histo
(
dates
)
(
round
<$>
count
))
treeData
::
FlowCmdM
env
err
m
treeData
::
FlowCmdM
env
err
m
...
...
src/Gargantext/Core/Viz/Types.hs
View file @
d37798c1
...
@@ -9,6 +9,8 @@ module Gargantext.Core.Viz.Types where
...
@@ -9,6 +9,8 @@ module Gargantext.Core.Viz.Types where
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Swagger
import
Data.Swagger
import
Data.Vector
(
Vector
)
import
qualified
Data.Vector
as
V
import
Protolude
import
Protolude
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
...
@@ -23,8 +25,8 @@ data Chart = ChartHisto | ChartScatter | ChartPie
...
@@ -23,8 +25,8 @@ data Chart = ChartHisto | ChartScatter | ChartPie
deriving
(
Generic
)
deriving
(
Generic
)
-- TODO use UTCTime
-- TODO use UTCTime
data
Histo
=
Histo
{
histo_dates
::
!
[
Text
]
data
Histo
=
Histo
{
histo_dates
::
!
(
Vector
Text
)
,
histo_count
::
!
[
Int
]
,
histo_count
::
!
(
Vector
Int
)
}
}
deriving
(
Show
,
Generic
)
deriving
(
Show
,
Generic
)
...
@@ -32,7 +34,7 @@ instance ToSchema Histo where
...
@@ -32,7 +34,7 @@ instance ToSchema Histo where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"histo_"
)
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"histo_"
)
instance
Arbitrary
Histo
instance
Arbitrary
Histo
where
where
arbitrary
=
elements
[
Histo
[
"2012"
]
[
1
]
arbitrary
=
elements
[
Histo
(
V
.
singleton
"2012"
)
(
V
.
singleton
1
)
,
Histo
[
"2013"
]
[
1
]
,
Histo
(
V
.
singleton
"2013"
)
(
V
.
singleton
1
)
]
]
deriveJSON
(
unPrefix
"histo_"
)
''
H
isto
deriveJSON
(
unPrefix
"histo_"
)
''
H
isto
src/Gargantext/Database/Action/Metrics.hs
View file @
d37798c1
...
@@ -18,6 +18,7 @@ module Gargantext.Database.Action.Metrics
...
@@ -18,6 +18,7 @@ module Gargantext.Database.Action.Metrics
import
Data.Map
(
Map
)
import
Data.Map
(
Map
)
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Data.Vector
(
Vector
)
import
Gargantext.API.Ngrams.Types
(
TabType
(
..
),
ngramsTypeFromTabType
)
import
Gargantext.API.Ngrams.Types
(
TabType
(
..
),
ngramsTypeFromTabType
)
import
Gargantext.API.Ngrams.Tools
(
filterListWithRoot
,
groupNodesByNgrams
,
Diagonal
(
..
),
getCoocByNgrams
,
mapTermListRoot
,
RootTerm
,
getRepo
)
import
Gargantext.API.Ngrams.Tools
(
filterListWithRoot
,
groupNodesByNgrams
,
Diagonal
(
..
),
getCoocByNgrams
,
mapTermListRoot
,
RootTerm
,
getRepo
)
...
@@ -33,7 +34,7 @@ import Gargantext.Core.Text.Metrics (scored, Scored(..), {-localMetrics, toScore
...
@@ -33,7 +34,7 @@ import Gargantext.Core.Text.Metrics (scored, Scored(..), {-localMetrics, toScore
getMetrics
::
FlowCmdM
env
err
m
getMetrics
::
FlowCmdM
env
err
m
=>
CorpusId
->
Maybe
ListId
->
TabType
->
Maybe
Limit
=>
CorpusId
->
Maybe
ListId
->
TabType
->
Maybe
Limit
->
m
(
Map
Text
(
ListType
,
Maybe
Text
),
[
Scored
Text
]
)
->
m
(
Map
Text
(
ListType
,
Maybe
Text
),
Vector
(
Scored
Text
)
)
getMetrics
cId
maybeListId
tabType
maybeLimit
=
do
getMetrics
cId
maybeListId
tabType
maybeLimit
=
do
(
ngs
,
_
,
myCooc
)
<-
getNgramsCooc
cId
maybeListId
tabType
maybeLimit
(
ngs
,
_
,
myCooc
)
<-
getNgramsCooc
cId
maybeListId
tabType
maybeLimit
pure
(
ngs
,
scored
myCooc
)
pure
(
ngs
,
scored
myCooc
)
...
...
src/Gargantext/Database/Action/Metrics/Lists.hs
View file @
d37798c1
...
@@ -56,5 +56,5 @@ getMetrics' cId maybeListId tabType maybeLimit = do
...
@@ -56,5 +56,5 @@ getMetrics' cId maybeListId tabType maybeLimit = do
{-
{-
_ <- Learn.grid 100 110 metrics' metrics'
_ <- Learn.grid 100 110 metrics' metrics'
--}
--}
pure
$
Map
.
fromListWith
(
<>
)
metrics
pure
$
Map
.
fromListWith
(
<>
)
$
Vec
.
toList
metrics
src/Gargantext/Database/Admin/Types/Hyperdata/List.hs
View file @
d37798c1
...
@@ -21,8 +21,10 @@ Portability : POSIX
...
@@ -21,8 +21,10 @@ Portability : POSIX
module
Gargantext.Database.Admin.Types.Hyperdata.List
module
Gargantext.Database.Admin.Types.Hyperdata.List
where
where
import
Data.Map
(
Map
)
import
Data.Vector
(
Vector
)
import
qualified
Data.Map
as
Map
--import qualified Data.Vector as V
import
Data.HashMap.Strict
(
HashMap
)
import
qualified
Data.HashMap.Strict
as
HM
import
Control.Applicative
import
Control.Applicative
import
Gargantext.Prelude
import
Gargantext.Prelude
...
@@ -34,11 +36,11 @@ import Gargantext.Database.Admin.Types.Metrics (ChartMetrics(..), Metrics)
...
@@ -34,11 +36,11 @@ import Gargantext.Database.Admin.Types.Metrics (ChartMetrics(..), Metrics)
------------------------------------------------------------------------
------------------------------------------------------------------------
data
HyperdataList
=
data
HyperdataList
=
HyperdataList
{
_hl_chart
::
!
(
Map
TabType
(
ChartMetrics
Histo
))
HyperdataList
{
_hl_chart
::
!
(
Hash
Map
TabType
(
ChartMetrics
Histo
))
,
_hl_list
::
!
(
Maybe
Text
)
,
_hl_list
::
!
(
Maybe
Text
)
,
_hl_pie
::
!
(
Map
TabType
(
ChartMetrics
Histo
))
,
_hl_pie
::
!
(
Hash
Map
TabType
(
ChartMetrics
Histo
))
,
_hl_scatter
::
!
(
Map
TabType
Metrics
)
,
_hl_scatter
::
!
(
Hash
Map
TabType
Metrics
)
,
_hl_tree
::
!
(
Map
TabType
(
ChartMetrics
[
NgramsTree
]
))
,
_hl_tree
::
!
(
HashMap
TabType
(
ChartMetrics
(
Vector
NgramsTree
)
))
}
deriving
(
Show
,
Generic
)
}
deriving
(
Show
,
Generic
)
-- HyperdataList { _hl_chart :: !(Maybe (ChartMetrics Histo))
-- HyperdataList { _hl_chart :: !(Maybe (ChartMetrics Histo))
-- , _hl_list :: !(Maybe Text)
-- , _hl_list :: !(Maybe Text)
...
@@ -49,11 +51,11 @@ data HyperdataList =
...
@@ -49,11 +51,11 @@ data HyperdataList =
defaultHyperdataList
::
HyperdataList
defaultHyperdataList
::
HyperdataList
defaultHyperdataList
=
defaultHyperdataList
=
HyperdataList
{
_hl_chart
=
Map
.
empty
HyperdataList
{
_hl_chart
=
HM
.
empty
,
_hl_list
=
Nothing
,
_hl_list
=
Nothing
,
_hl_pie
=
Map
.
empty
,
_hl_pie
=
HM
.
empty
,
_hl_scatter
=
Map
.
empty
,
_hl_scatter
=
HM
.
empty
,
_hl_tree
=
Map
.
empty
,
_hl_tree
=
HM
.
empty
}
}
------------------------------------------------------------------------
------------------------------------------------------------------------
...
...
src/Gargantext/Database/Admin/Types/Metrics.hs
View file @
d37798c1
...
@@ -5,6 +5,8 @@ module Gargantext.Database.Admin.Types.Metrics where
...
@@ -5,6 +5,8 @@ module Gargantext.Database.Admin.Types.Metrics where
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Swagger
import
Data.Swagger
import
Data.Vector
(
Vector
)
import
qualified
Data.Vector
as
V
import
Protolude
import
Protolude
import
Test.QuickCheck.Arbitrary
import
Test.QuickCheck.Arbitrary
...
@@ -13,15 +15,15 @@ import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger, wellNamedSchema)
...
@@ -13,15 +15,15 @@ import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger, wellNamedSchema)
----------------------------------------------------------------------------
----------------------------------------------------------------------------
data
Metrics
=
Metrics
newtype
Metrics
=
Metrics
{
metrics_data
::
[
Metric
]
}
{
metrics_data
::
Vector
Metric
}
deriving
(
Generic
,
Show
)
deriving
(
Generic
,
Show
)
instance
ToSchema
Metrics
where
instance
ToSchema
Metrics
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"metrics_"
)
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"metrics_"
)
instance
Arbitrary
Metrics
instance
Arbitrary
Metrics
where
where
arbitrary
=
Metrics
<$>
arbitrary
arbitrary
=
(
Metrics
.
V
.
fromList
)
<$>
arbitrary
data
Metric
=
Metric
data
Metric
=
Metric
{
m_label
::
!
Text
{
m_label
::
!
Text
...
@@ -43,7 +45,7 @@ deriveJSON (unPrefix "metrics_") ''Metrics
...
@@ -43,7 +45,7 @@ deriveJSON (unPrefix "metrics_") ''Metrics
deriveJSON
(
unPrefix
"m_"
)
''
M
etric
deriveJSON
(
unPrefix
"m_"
)
''
M
etric
data
ChartMetrics
a
=
ChartMetrics
{
chartMetrics_data
::
a
}
newtype
ChartMetrics
a
=
ChartMetrics
{
chartMetrics_data
::
a
}
deriving
(
Generic
,
Show
)
deriving
(
Generic
,
Show
)
instance
(
Typeable
a
,
ToSchema
a
)
=>
ToSchema
(
ChartMetrics
a
)
where
instance
(
Typeable
a
,
ToSchema
a
)
=>
ToSchema
(
ChartMetrics
a
)
where
...
...
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