Commit e4de05a3 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[cache] last modification header cache: first drafts

parent 19071e4b
...@@ -121,3 +121,19 @@ Then you can log in with `user1:1resu`. ...@@ -121,3 +121,19 @@ Then you can log in with `user1:1resu`.
stack --docker exec gargantext-cli -- CorpusFromGarg.csv ListFromGarg.csv Ouput.json stack --docker exec gargantext-cli -- CorpusFromGarg.csv ListFromGarg.csv Ouput.json
Haskell fused-effects-profile
https://www.simplehaskell.org/
## REPL tips
Some tips to use the Haskell REPL.
### Query database for node
``` haskell
:set -XFlexibleContexts
:m + Data.Aeson
:m + Data.Proxy
let getN n = getNode n :: Cmd GargError (Gargantext.Core.Types.Node Value)
runCmdRepl $ getN <id>
```
{ pkgs ? import ./pinned-19.09.nix {} }: { pkgs ? import ./pinned-19.09.nix {} }:
let
hie = (import (pkgs.fetchFromGitHub {
owner="domenkozar";
repo="hie-nix";
rev="e3113da";
sha256="05rkzjvzywsg66iafm84xgjlkf27yfbagrdcb8sc9fd59hrzyiqk";
}) {}).hie84;
in
pkgs.mkShell { pkgs.mkShell {
buildInputs = with pkgs; [ buildInputs = with pkgs; [
docker-compose docker-compose
#hie
#glibc #glibc
#gmp #gmp
#gsl #gsl
......
...@@ -49,42 +49,42 @@ type ScatterAPI = Summary "SepGen IncExc metrics" ...@@ -49,42 +49,42 @@ 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 '[JSON] (HashedResponse Metrics) :> Header "If-Modified-Since" Text
:> Get (Headers '[Servant.Header "Last-Modified"] Text Metrics)
:<|> Summary "Scatter update" :<|> Summary "Scatter update"
:> QueryParam "list" ListId :> QueryParam "list" ListId
:> QueryParamR "ngramsType" TabType :> QueryParamR "ngramsType" TabType
:> QueryParam "limit" Int :> QueryParam "limit" Int
:> Post '[JSON] () :> Post '[JSON] ()
:<|> "md5" :>
Summary "Scatter MD5"
:> QueryParam "list" ListId
:> QueryParamR "ngramsType" TabType
:> Get '[JSON] Text
scatterApi :: NodeId -> GargServer ScatterAPI scatterApi :: NodeId -> GargServer ScatterAPI
scatterApi id' = getScatter id' scatterApi id' = getScatter id'
:<|> updateScatter id' :<|> updateScatter id'
:<|> getScatterMD5 id'
getScatter :: FlowCmdM env err m => getScatter :: FlowCmdM env err m =>
CorpusId CorpusId
-> Maybe ListId -> Maybe ListId
-> TabType -> TabType
-> Maybe Limit -> Maybe Limit
-> m (HashedResponse Metrics) -> Maybe Text
getScatter cId maybeListId tabType _maybeLimit = do -> m Metrics
getScatter cId maybeListId tabType _maybeLimit mLMSent = do
listId <- case maybeListId of listId <- case maybeListId of
Just lid -> pure lid Just lid -> pure lid
Nothing -> defaultList cId Nothing -> defaultList cId
node <- getNodeWith listId (Proxy :: Proxy HyperdataList) node <- getNodeWith listId (Proxy :: Proxy HyperdataList)
let HyperdataList { hd_scatter = mChart } = node ^. node_hyperdata let HyperdataList { hd_scatter = mChart, hd_last_modified = mLM } = node ^. node_hyperdata
chart <- case mChart of (chart, lastModified) <- case mLM of
Just chart -> pure chart Nothing -> do
Nothing -> do
updateScatter' cId maybeListId tabType Nothing updateScatter' cId maybeListId tabType Nothing
Just lastModified ->
case mChart of
Nothing -> do
updateScatter' cId maybeListId tabType Nothing
Just chart -> pure chart
pure $ constructHashedResponse chart pure $ addHeader lastModified chart
updateScatter :: FlowCmdM env err m => updateScatter :: FlowCmdM env err m =>
CorpusId CorpusId
...@@ -396,4 +396,4 @@ getTreeMD5 :: FlowCmdM env err m => ...@@ -396,4 +396,4 @@ getTreeMD5 :: FlowCmdM env err m =>
-> m Text -> m Text
getTreeMD5 cId maybeListId tabType listType = do getTreeMD5 cId maybeListId tabType listType = do
HashedResponse { md5 = md5' } <- getTree cId Nothing Nothing maybeListId tabType listType HashedResponse { md5 = md5' } <- getTree cId Nothing Nothing maybeListId tabType listType
pure md5' pure md5'
\ No newline at end of file
...@@ -233,6 +233,7 @@ data HyperdataList = ...@@ -233,6 +233,7 @@ data HyperdataList =
, hd_pie :: !(Maybe (ChartMetrics Histo)) , hd_pie :: !(Maybe (ChartMetrics Histo))
, hd_scatter :: !(Maybe Metrics) , hd_scatter :: !(Maybe Metrics)
, hd_tree :: !(Maybe (ChartMetrics [MyTree])) , hd_tree :: !(Maybe (ChartMetrics [MyTree]))
, hd_last_modified :: !(Maybe Text)
} deriving (Show, Generic) } deriving (Show, Generic)
$(deriveJSON (unPrefix "hd_") ''HyperdataList) $(deriveJSON (unPrefix "hd_") ''HyperdataList)
......
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