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
147
Issues
147
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
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
Hide 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
where
import
Control.Lens
import
qualified
Data.Map
as
Map
import
Data.Time
(
UTCTime
)
import
Data.Text
(
Text
)
import
Servant
import
Gargantext.API.HashedResponse
import
Gargantext.API.Ngrams
import
Gargantext.API.Ngrams.NTree
...
...
@@ -39,8 +42,6 @@ import Gargantext.Prelude
import
Gargantext.Text.Metrics
(
Scored
(
..
))
import
Gargantext.Viz.Chart
import
Gargantext.Viz.Types
import
Servant
import
qualified
Data.Map
as
Map
import
qualified
Gargantext.Database.Action.Metrics
as
Metrics
-------------------------------------------------------------
...
...
@@ -49,7 +50,8 @@ type ScatterAPI = Summary "SepGen IncExc metrics"
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
:>
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"
:>
QueryParam
"list"
ListId
:>
QueryParamR
"ngramsType"
TabType
...
...
@@ -71,8 +73,9 @@ getScatter :: FlowCmdM env err m =>
->
Maybe
ListId
->
TabType
->
Maybe
Limit
->
m
(
HashedResponse
Metrics
)
getScatter
cId
maybeListId
tabType
_maybeLimit
=
do
->
Maybe
Text
->
m
(
Headers
'[
H
eader
"X-Hash"
Text
]
(
HashedResponse
Metrics
))
getScatter
cId
maybeListId
tabType
_maybeLimit
mhHash
=
do
listId
<-
case
maybeListId
of
Just
lid
->
pure
lid
Nothing
->
defaultList
cId
...
...
@@ -84,7 +87,16 @@ getScatter cId maybeListId tabType _maybeLimit = do
Nothing
->
do
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
=>
CorpusId
...
...
@@ -126,7 +138,8 @@ getScatterHash :: FlowCmdM env err m =>
->
TabType
->
m
Text
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
------------------------------------------------------------------------
get
::
RepoCmdM
env
err
m
=>
ListId
->
m
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
get
::
RepoCmdM
env
err
m
=>
ListId
->
m
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
get
lId
=
do
lst
<-
get'
lId
let
(
NodeId
id
)
=
lId
...
...
@@ -108,17 +108,17 @@ postAsync' :: FlowCmdM env err m
postAsync'
l
(
WithFile
_
m
_
)
logStatus
=
do
logStatus
JobLog
{
_scst_succeeded
=
Just
0
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
}
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
}
_r
<-
post
l
m
pure
JobLog
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
0
,
_scst_events
=
Just
[]
}
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
0
,
_scst_events
=
Just
[]
}
data
WithFile
=
WithFile
{
_wf_filetype
::
!
FileType
...
...
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