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
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
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
d86ab2a1
Commit
d86ab2a1
authored
Oct 02, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[charts] fix HyperdataList so that charts are per tabType
parent
994c72a7
Pipeline
#1114
failed with stage
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
45 additions
and
18 deletions
+45
-18
Metrics.hs
src/Gargantext/API/Metrics.hs
+19
-11
Types.hs
src/Gargantext/API/Ngrams/Types.hs
+5
-2
List.hs
src/Gargantext/Database/Admin/Types/Hyperdata/List.hs
+21
-5
No files found.
src/Gargantext/API/Metrics.hs
View file @
d86ab2a1
...
...
@@ -20,8 +20,8 @@ module Gargantext.API.Metrics
import
Control.Lens
import
qualified
Data.Map
as
Map
import
Data.Time
(
UTCTime
)
import
Data.Text
(
Text
)
import
Data.Time
(
UTCTime
)
import
Servant
import
Gargantext.API.HashedResponse
...
...
@@ -30,7 +30,7 @@ import Gargantext.API.Ngrams.Types
import
Gargantext.API.Prelude
(
GargServer
)
import
Gargantext.Core.Types
(
CorpusId
,
Limit
,
ListId
,
ListType
(
..
))
import
Gargantext.Database.Action.Flow
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataList
(
..
))
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataList
(
..
)
,
hl_chart
,
hl_pie
,
hl_scatter
,
hl_tree
)
import
Gargantext.Database.Admin.Types.Metrics
(
ChartMetrics
(
..
),
Metric
(
..
),
Metrics
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
NodeId
)
import
Gargantext.Database.Prelude
...
...
@@ -77,7 +77,8 @@ getScatter cId maybeListId tabType _maybeLimit = do
Just
lid
->
pure
lid
Nothing
->
defaultList
cId
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
let
HyperdataList
{
_hl_scatter
=
mChart
}
=
node
^.
node_hyperdata
let
HyperdataList
{
_hl_scatter
=
scatterMap
}
=
node
^.
node_hyperdata
mChart
=
Map
.
lookup
tabType
scatterMap
chart
<-
case
mChart
of
Just
chart
->
pure
chart
...
...
@@ -120,7 +121,8 @@ updateScatter' cId maybeListId tabType maybeLimit = do
Nothing
->
defaultList
cId
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
let
hl
=
node
^.
node_hyperdata
_
<-
updateHyperdata
listId
$
hl
{
_hl_scatter
=
Just
$
Metrics
metrics
}
scatterMap
=
hl
^.
hl_scatter
_
<-
updateHyperdata
listId
$
hl
{
_hl_scatter
=
Map
.
insert
tabType
(
Metrics
metrics
)
scatterMap
}
pure
$
Metrics
metrics
...
...
@@ -169,7 +171,8 @@ getChart cId _start _end maybeListId tabType = do
Just
lid
->
pure
lid
Nothing
->
defaultList
cId
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
let
HyperdataList
{
_hl_chart
=
mChart
}
=
node
^.
node_hyperdata
let
HyperdataList
{
_hl_chart
=
chartMap
}
=
node
^.
node_hyperdata
mChart
=
Map
.
lookup
tabType
chartMap
chart
<-
case
mChart
of
Just
chart
->
pure
chart
...
...
@@ -198,14 +201,15 @@ updateChart' :: HasNodeError err =>
->
TabType
->
Maybe
Limit
->
Cmd
err
(
ChartMetrics
Histo
)
updateChart'
cId
maybeListId
_
tabType
_maybeLimit
=
do
updateChart'
cId
maybeListId
tabType
_maybeLimit
=
do
listId
<-
case
maybeListId
of
Just
lid
->
pure
lid
Nothing
->
defaultList
cId
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
let
hl
=
node
^.
node_hyperdata
chartMap
=
hl
^.
hl_chart
h
<-
histoData
cId
_
<-
updateHyperdata
listId
$
hl
{
_hl_chart
=
Just
$
ChartMetrics
h
}
_
<-
updateHyperdata
listId
$
hl
{
_hl_chart
=
Map
.
insert
tabType
(
ChartMetrics
h
)
chartMap
}
pure
$
ChartMetrics
h
...
...
@@ -253,7 +257,8 @@ getPie cId _start _end maybeListId tabType = do
Just
lid
->
pure
lid
Nothing
->
defaultList
cId
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
let
HyperdataList
{
_hl_pie
=
mChart
}
=
node
^.
node_hyperdata
let
HyperdataList
{
_hl_pie
=
pieMap
}
=
node
^.
node_hyperdata
mChart
=
Map
.
lookup
tabType
pieMap
chart
<-
case
mChart
of
Just
chart
->
pure
chart
...
...
@@ -288,9 +293,10 @@ updatePie' cId maybeListId tabType _maybeLimit = do
Nothing
->
defaultList
cId
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
let
hl
=
node
^.
node_hyperdata
pieMap
=
hl
^.
hl_pie
p
<-
chartData
cId
(
ngramsTypeFromTabType
tabType
)
MapTerm
_
<-
updateHyperdata
listId
$
hl
{
_hl_pie
=
Just
$
ChartMetrics
p
}
_
<-
updateHyperdata
listId
$
hl
{
_hl_pie
=
Map
.
insert
tabType
(
ChartMetrics
p
)
pieMa
p
}
pure
$
ChartMetrics
p
...
...
@@ -348,7 +354,8 @@ getTree cId _start _end maybeListId tabType listType = do
Nothing
->
defaultList
cId
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
let
HyperdataList
{
_hl_tree
=
mChart
}
=
node
^.
node_hyperdata
let
HyperdataList
{
_hl_tree
=
treeMap
}
=
node
^.
node_hyperdata
mChart
=
Map
.
lookup
tabType
treeMap
chart
<-
case
mChart
of
Just
chart
->
pure
chart
...
...
@@ -384,8 +391,9 @@ updateTree' cId maybeListId tabType listType = do
node
<-
getNodeWith
listId
(
Proxy
::
Proxy
HyperdataList
)
let
hl
=
node
^.
node_hyperdata
treeMap
=
hl
^.
hl_tree
t
<-
treeData
cId
(
ngramsTypeFromTabType
tabType
)
listType
_
<-
updateHyperdata
listId
$
hl
{
_hl_tree
=
Just
$
ChartMetrics
t
}
_
<-
updateHyperdata
listId
$
hl
{
_hl_tree
=
Map
.
insert
tabType
(
ChartMetrics
t
)
treeMap
}
pure
$
ChartMetrics
t
...
...
src/Gargantext/API/Ngrams/Types.hs
View file @
d86ab2a1
...
...
@@ -59,7 +59,7 @@ import qualified Gargantext.Database.Query.Table.Ngrams as TableNgrams
data
TabType
=
Docs
|
Trash
|
MoreFav
|
MoreTrash
|
Terms
|
Sources
|
Authors
|
Institutes
|
Contacts
deriving
(
Generic
,
Enum
,
Bounde
d
,
Show
)
deriving
(
Bounded
,
Enum
,
Eq
,
Generic
,
Or
d
,
Show
)
instance
FromHttpApiData
TabType
where
...
...
@@ -76,7 +76,6 @@ instance FromHttpApiData TabType
parseUrlPiece
"Contacts"
=
pure
Contacts
parseUrlPiece
_
=
Left
"Unexpected value of TabType"
instance
ToParamSchema
TabType
instance
ToJSON
TabType
instance
FromJSON
TabType
...
...
@@ -84,6 +83,10 @@ instance ToSchema TabType
instance
Arbitrary
TabType
where
arbitrary
=
elements
[
minBound
..
maxBound
]
instance
FromJSONKey
TabType
where
fromJSONKey
=
genericFromJSONKey
defaultJSONKeyOptions
instance
ToJSONKey
TabType
where
toJSONKey
=
genericToJSONKey
defaultJSONKeyOptions
newtype
MSet
a
=
MSet
(
Map
a
()
)
deriving
(
Eq
,
Ord
,
Show
,
Generic
,
Arbitrary
,
Semigroup
,
Monoid
)
...
...
src/Gargantext/Database/Admin/Types/Hyperdata/List.hs
View file @
d86ab2a1
...
...
@@ -21,23 +21,39 @@ Portability : POSIX
module
Gargantext.Database.Admin.Types.Hyperdata.List
where
import
Data.Map
(
Map
)
import
qualified
Data.Map
as
Map
import
Gargantext.Prelude
import
Gargantext.Core.Viz.Types
(
Histo
(
..
))
import
Gargantext.API.Ngrams.NTree
(
MyTree
)
import
Gargantext.API.Ngrams.Types
(
TabType
)
import
Gargantext.Database.Admin.Types.Hyperdata.Prelude
import
Gargantext.Database.Admin.Types.Metrics
(
ChartMetrics
(
..
),
Metrics
)
------------------------------------------------------------------------
data
HyperdataList
=
HyperdataList
{
_hl_chart
::
!
(
Ma
yb
e
(
ChartMetrics
Histo
))
HyperdataList
{
_hl_chart
::
!
(
Ma
p
TabTyp
e
(
ChartMetrics
Histo
))
,
_hl_list
::
!
(
Maybe
Text
)
,
_hl_pie
::
!
(
Ma
yb
e
(
ChartMetrics
Histo
))
,
_hl_scatter
::
!
(
Ma
yb
e
Metrics
)
,
_hl_tree
::
!
(
Ma
yb
e
(
ChartMetrics
[
MyTree
]))
,
_hl_pie
::
!
(
Ma
p
TabTyp
e
(
ChartMetrics
Histo
))
,
_hl_scatter
::
!
(
Ma
p
TabTyp
e
Metrics
)
,
_hl_tree
::
!
(
Ma
p
TabTyp
e
(
ChartMetrics
[
MyTree
]))
}
deriving
(
Show
,
Generic
)
-- HyperdataList { _hl_chart :: !(Maybe (ChartMetrics Histo))
-- , _hl_list :: !(Maybe Text)
-- , _hl_pie :: !(Maybe (ChartMetrics Histo))
-- , _hl_scatter :: !(Maybe Metrics)
-- , _hl_tree :: !(Maybe (ChartMetrics [MyTree]))
-- } deriving (Show, Generic)
defaultHyperdataList
::
HyperdataList
defaultHyperdataList
=
HyperdataList
Nothing
Nothing
Nothing
Nothing
Nothing
defaultHyperdataList
=
HyperdataList
{
_hl_chart
=
Map
.
empty
,
_hl_list
=
Nothing
,
_hl_pie
=
Map
.
empty
,
_hl_scatter
=
Map
.
empty
,
_hl_tree
=
Map
.
empty
}
data
HyperdataListCooc
=
HyperdataListCooc
{
_hlc_preferences
::
!
Text
}
...
...
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