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
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
7ac399b1
Commit
7ac399b1
authored
Jul 20, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[metrics] trying to get 304 status code to work
parent
7b42e0f8
Pipeline
#961
canceled with stage
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
17 deletions
+30
-17
Metrics.hs
src/Gargantext/API/Metrics.hs
+20
-7
List.hs
src/Gargantext/API/Ngrams/List.hs
+10
-10
No files found.
src/Gargantext/API/Metrics.hs
View file @
7ac399b1
...
@@ -19,8 +19,11 @@ module Gargantext.API.Metrics
...
@@ -19,8 +19,11 @@ module Gargantext.API.Metrics
where
where
import
Control.Lens
import
Control.Lens
import
qualified
Data.Map
as
Map
import
Data.Time
(
UTCTime
)
import
Data.Time
(
UTCTime
)
import
Data.Text
(
Text
)
import
Data.Text
(
Text
)
import
Servant
import
Gargantext.API.HashedResponse
import
Gargantext.API.HashedResponse
import
Gargantext.API.Ngrams
import
Gargantext.API.Ngrams
import
Gargantext.API.Ngrams.NTree
import
Gargantext.API.Ngrams.NTree
...
@@ -39,8 +42,6 @@ import Gargantext.Prelude
...
@@ -39,8 +42,6 @@ import Gargantext.Prelude
import
Gargantext.Text.Metrics
(
Scored
(
..
))
import
Gargantext.Text.Metrics
(
Scored
(
..
))
import
Gargantext.Viz.Chart
import
Gargantext.Viz.Chart
import
Gargantext.Viz.Types
import
Gargantext.Viz.Types
import
Servant
import
qualified
Data.Map
as
Map
import
qualified
Gargantext.Database.Action.Metrics
as
Metrics
import
qualified
Gargantext.Database.Action.Metrics
as
Metrics
-------------------------------------------------------------
-------------------------------------------------------------
...
@@ -49,7 +50,8 @@ type ScatterAPI = Summary "SepGen IncExc metrics"
...
@@ -49,7 +50,8 @@ type ScatterAPI = Summary "SepGen IncExc metrics"
:>
QueryParam
"list"
ListId
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParam
"limit"
Int
:>
QueryParam
"limit"
Int
:>
Get
'[
J
SON
]
(
HashedResponse
Metrics
)
:>
Header
"X-Hash"
Text
:>
Get
'[
J
SON
]
(
Headers
'[
H
eader
"X-Hash"
Text
]
(
HashedResponse
Metrics
))
:<|>
Summary
"Scatter update"
:<|>
Summary
"Scatter update"
:>
QueryParam
"list"
ListId
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
:>
QueryParamR
"ngramsType"
TabType
...
@@ -71,8 +73,9 @@ getScatter :: FlowCmdM env err m =>
...
@@ -71,8 +73,9 @@ getScatter :: FlowCmdM env err m =>
->
Maybe
ListId
->
Maybe
ListId
->
TabType
->
TabType
->
Maybe
Limit
->
Maybe
Limit
->
m
(
HashedResponse
Metrics
)
->
Maybe
Text
getScatter
cId
maybeListId
tabType
_maybeLimit
=
do
->
m
(
Headers
'[
H
eader
"X-Hash"
Text
]
(
HashedResponse
Metrics
))
getScatter
cId
maybeListId
tabType
_maybeLimit
mhHash
=
do
listId
<-
case
maybeListId
of
listId
<-
case
maybeListId
of
Just
lid
->
pure
lid
Just
lid
->
pure
lid
Nothing
->
defaultList
cId
Nothing
->
defaultList
cId
...
@@ -84,7 +87,16 @@ getScatter cId maybeListId tabType _maybeLimit = do
...
@@ -84,7 +87,16 @@ getScatter cId maybeListId tabType _maybeLimit = do
Nothing
->
do
Nothing
->
do
updateScatter'
cId
maybeListId
tabType
Nothing
updateScatter'
cId
maybeListId
tabType
Nothing
pure
$
constructHashedResponse
chart
let
r
=
constructHashedResponse
chart
-- TODO send 304 if hashes equal, 200 with response otherwise
if
mhHash
==
(
Just
$
hash
r
)
then
throwError
$
ServantErr
{
errHTTPCode
=
304
,
errReasonPhrase
=
"Hashes match"
,
errBody
=
""
,
errHeaders
=
[]
}
else
pure
$
addHeader
(
hash
r
)
r
updateScatter
::
FlowCmdM
env
err
m
=>
updateScatter
::
FlowCmdM
env
err
m
=>
CorpusId
CorpusId
...
@@ -126,7 +138,8 @@ getScatterHash :: FlowCmdM env err m =>
...
@@ -126,7 +138,8 @@ getScatterHash :: FlowCmdM env err m =>
->
TabType
->
TabType
->
m
Text
->
m
Text
getScatterHash
cId
maybeListId
tabType
=
do
getScatterHash
cId
maybeListId
tabType
=
do
hash
<$>
getScatter
cId
maybeListId
tabType
Nothing
r
<-
getScatter
cId
maybeListId
tabType
Nothing
Nothing
pure
$
hash
$
getResponse
r
-------------------------------------------------------------
-------------------------------------------------------------
...
...
src/Gargantext/API/Ngrams/List.hs
View file @
7ac399b1
...
@@ -56,8 +56,8 @@ instance ToJSON a => MimeRender HTML a where
...
@@ -56,8 +56,8 @@ instance ToJSON a => MimeRender HTML a where
------------------------------------------------------------------------
------------------------------------------------------------------------
get
::
RepoCmdM
env
err
m
get
::
RepoCmdM
env
err
m
=>
=>
ListId
->
m
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
ListId
->
m
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
get
lId
=
do
get
lId
=
do
lst
<-
get'
lId
lst
<-
get'
lId
let
(
NodeId
id
)
=
lId
let
(
NodeId
id
)
=
lId
...
...
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