Commit 50fb44bf authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[metrics] remove X-Hash header

parent 0d6763e2
...@@ -23,7 +23,6 @@ import qualified Data.Map as Map ...@@ -23,7 +23,6 @@ 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 Servant
import Servant.Server.Internal.ServerError (ServerError(..))
import Gargantext.API.HashedResponse import Gargantext.API.HashedResponse
import Gargantext.API.Ngrams import Gargantext.API.Ngrams
...@@ -51,8 +50,7 @@ type ScatterAPI = Summary "SepGen IncExc metrics" ...@@ -51,8 +50,7 @@ type ScatterAPI = Summary "SepGen IncExc metrics"
:> QueryParam "list" ListId :> QueryParam "list" ListId
:> QueryParamR "ngramsType" TabType :> QueryParamR "ngramsType" TabType
:> QueryParam "limit" Int :> QueryParam "limit" Int
:> Header "X-Hash" Text :> Get '[JSON] (HashedResponse Metrics)
:> Get '[JSON] (Headers '[Header "X-Hash" Text] (HashedResponse Metrics))
:<|> Summary "Scatter update" :<|> Summary "Scatter update"
:> QueryParam "list" ListId :> QueryParam "list" ListId
:> QueryParamR "ngramsType" TabType :> QueryParamR "ngramsType" TabType
...@@ -74,9 +72,8 @@ getScatter :: FlowCmdM env err m => ...@@ -74,9 +72,8 @@ getScatter :: FlowCmdM env err m =>
-> Maybe ListId -> Maybe ListId
-> TabType -> TabType
-> Maybe Limit -> Maybe Limit
-> Maybe Text -> m (HashedResponse Metrics)
-> m (Headers '[Header "X-Hash" Text] (HashedResponse Metrics)) getScatter cId maybeListId tabType _maybeLimit = do
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
...@@ -88,16 +85,7 @@ getScatter cId maybeListId tabType _maybeLimit mhHash = do ...@@ -88,16 +85,7 @@ getScatter cId maybeListId tabType _maybeLimit mhHash = do
Nothing -> do Nothing -> do
updateScatter' cId maybeListId tabType Nothing updateScatter' cId maybeListId tabType Nothing
let r = constructHashedResponse chart pure $ constructHashedResponse chart
-- TODO send 304 if hashes equal, 200 with response otherwise
if mhHash == (Just $ hash r) then
throwError $ ServerError { 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
...@@ -139,8 +127,7 @@ getScatterHash :: FlowCmdM env err m => ...@@ -139,8 +127,7 @@ getScatterHash :: FlowCmdM env err m =>
-> TabType -> TabType
-> m Text -> m Text
getScatterHash cId maybeListId tabType = do getScatterHash cId maybeListId tabType = do
r <- getScatter cId maybeListId tabType Nothing Nothing hash <$> getScatter cId maybeListId tabType Nothing
pure $ hash $ getResponse r
------------------------------------------------------------- -------------------------------------------------------------
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment