Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Grégoire Locqueville
purescript-gargantext
Commits
66f2d55d
Commit
66f2d55d
authored
Jul 16, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Crypto] Hash API (hash fun)
parent
f25271ad
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
77 additions
and
84 deletions
+77
-84
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+6
-6
Common.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Common.purs
+5
-5
Histo.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Histo.purs
+12
-14
Metrics.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Metrics.purs
+6
-6
Pie.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Pie.purs
+13
-15
Tree.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Tree.purs
+6
-6
Texts.purs
src/Gargantext/Components/Nodes/Texts.purs
+0
-1
Ends.purs
src/Gargantext/Ends.purs
+4
-4
Loader.purs
src/Gargantext/Hooks/Loader.purs
+23
-25
Routes.purs
src/Gargantext/Routes.purs
+2
-2
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
66f2d55d
...
@@ -362,14 +362,14 @@ loadPage session { corpusId, listId, nodeId, query, tabType } = do
...
@@ -362,14 +362,14 @@ loadPage session { corpusId, listId, nodeId, query, tabType } = do
--liftEffect $ log3 "loading documents page: loadPage with Offset and limit" offset limit
--liftEffect $ log3 "loading documents page: loadPage with Offset and limit" offset limit
-- res <- get $ toUrl endConfigStateful Back (Tab tabType offset limit (convOrderBy <$> orderBy)) (Just nodeId)
-- res <- get $ toUrl endConfigStateful Back (Tab tabType offset limit (convOrderBy <$> orderBy)) (Just nodeId)
let p = NodeAPI Node (Just nodeId) $ "table" <> "?tabType=" <> (showTabType' tabType)
let p = NodeAPI Node (Just nodeId) $ "table" <> "?tabType=" <> (showTabType' tabType)
HashedResponse {
md5
, value: res } <- (get session p) :: Aff (HashedResponse (TableResult Response))
HashedResponse {
hash
, value: res } <- (get session p) :: Aff (HashedResponse (TableResult Response))
let docs = res2corpus <$> res.docs
let docs = res2corpus <$> res.docs
let ret = if mock then
let ret = if mock then
--Tuple 0 (take limit $ drop offset sampleData)
--Tuple 0 (take limit $ drop offset sampleData)
Tuple 0 sampleData
Tuple 0 sampleData
else
else
Tuple res.count docs
Tuple res.count docs
pure $ HashedResponse {
md5
, value: ret }
pure $ HashedResponse {
hash
, value: ret }
where
where
res2corpus :: Response -> DocumentsView
res2corpus :: Response -> DocumentsView
res2corpus (Response r) =
res2corpus (Response r) =
...
@@ -382,9 +382,9 @@ loadPage session { corpusId, listId, nodeId, query, tabType } = do
...
@@ -382,9 +382,9 @@ loadPage session { corpusId, listId, nodeId, query, tabType } = do
, ngramCount : r.ngramCount
, ngramCount : r.ngramCount
}
}
getPage
MD5
:: Session -> PageParams -> Aff String
getPage
Hash
:: Session -> PageParams -> Aff String
getPage
MD5
session { corpusId, listId, nodeId, query, tabType } = do
getPage
Hash
session { corpusId, listId, nodeId, query, tabType } = do
let p = NodeAPI Node (Just nodeId) $ "table/
md5
" <> "?tabType=" <> (showTabType' tabType)
let p = NodeAPI Node (Just nodeId) $ "table/
hash
" <> "?tabType=" <> (showTabType' tabType)
(get session p) :: Aff String
(get session p) :: Aff String
...
@@ -403,7 +403,7 @@ pageLayoutCpt :: R.Component PageLayoutProps
...
@@ -403,7 +403,7 @@ pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt = R.hooksComponent "G.C.DocsTable.pageLayout" cpt where
pageLayoutCpt = R.hooksComponent "G.C.DocsTable.pageLayout" cpt where
cpt props@{frontends, session, nodeId, listId, corpusId, tabType, query, params} _ =
cpt props@{frontends, session, nodeId, listId, corpusId, tabType, query, params} _ =
-- useLoader path (loadPage session) paint
-- useLoader path (loadPage session) paint
useLoaderWithCache path keyFunc (getPage
MD5
session) (loadPage session) paint
useLoaderWithCache path keyFunc (getPage
Hash
session) (loadPage session) paint
where
where
path = { nodeId, listId, corpusId, tabType, query, params }
path = { nodeId, listId, corpusId, tabType, query, params }
paint (Tuple count docs) = page params (newProps count) docs
paint (Tuple count docs) = page params (newProps count) docs
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Common.purs
View file @
66f2d55d
...
@@ -9,7 +9,7 @@ import Reactix as R
...
@@ -9,7 +9,7 @@ import Reactix as R
import Gargantext.Prelude
import Gargantext.Prelude
import Gargantext.Components.Nodes.Corpus.Chart.Types (Reload, Path, Props, MetricsProps, ReloadPath)
import Gargantext.Components.Nodes.Corpus.Chart.Types (Reload, Path, Props, MetricsProps, ReloadPath)
import Gargantext.Hooks.Loader (
MD5
, HashedResponse, useLoader, useLoaderWithCache, useLoaderWithCacheAPI)
import Gargantext.Hooks.Loader (
Hash
, HashedResponse, useLoader, useLoaderWithCache, useLoaderWithCacheAPI)
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session)
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.CacheAPI as GUC
...
@@ -33,7 +33,7 @@ metricsLoadViewCpt = R.hooksComponent "G.C.N.C.C.metricsLoadView" cpt
...
@@ -33,7 +33,7 @@ metricsLoadViewCpt = R.hooksComponent "G.C.N.C.C.metricsLoadView" cpt
loaded { path, reload, session } l
loaded { path, reload, session } l
type MetricsWithCacheLoadViewProps res ret = (
type MetricsWithCacheLoadViewProps res ret = (
getMetrics
MD5 :: Session -> ReloadPath -> Aff MD5
getMetrics
Hash :: Session -> ReloadPath -> Aff Hash
, handleResponse :: HashedResponse res -> ret
, handleResponse :: HashedResponse res -> ret
, loaded :: Record MetricsProps -> ret -> R.Element
, loaded :: Record MetricsProps -> ret -> R.Element
, mkRequest :: ReloadPath -> GUC.Request
, mkRequest :: ReloadPath -> GUC.Request
...
@@ -48,13 +48,13 @@ metricsWithCacheLoadViewCpt :: forall res ret. DecodeJson res =>
...
@@ -48,13 +48,13 @@ metricsWithCacheLoadViewCpt :: forall res ret. DecodeJson res =>
R.Component (MetricsWithCacheLoadViewProps res ret)
R.Component (MetricsWithCacheLoadViewProps res ret)
metricsWithCacheLoadViewCpt = R.hooksComponent "G.C.N.C.C.metricsWithCacheLoadView" cpt
metricsWithCacheLoadViewCpt = R.hooksComponent "G.C.N.C.C.metricsWithCacheLoadView" cpt
where
where
cpt { getMetrics
MD5
, handleResponse, loaded, mkRequest, path, reload, session } _ = do
cpt { getMetrics
Hash
, handleResponse, loaded, mkRequest, path, reload, session } _ = do
-- useLoaderWithCache (fst reload /\ path) (metricsKeyFunc keyFunc) (getMetrics
MD5
session) (getMetrics session) $ \l ->
-- useLoaderWithCache (fst reload /\ path) (metricsKeyFunc keyFunc) (getMetrics
Hash
session) (getMetrics session) $ \l ->
-- loaded session path reload l
-- loaded session path reload l
-- metricsKeyFunc keyFunc st@(_ /\ { corpusId, listId, tabType }) =
-- metricsKeyFunc keyFunc st@(_ /\ { corpusId, listId, tabType }) =
-- "metrics-" <> (show tabType) <> "-" <> (show corpusId) <> "-" <> (show listId) <> "--" <> (keyFunc st)
-- "metrics-" <> (show tabType) <> "-" <> (show corpusId) <> "-" <> (show listId) <> "--" <> (keyFunc st)
useLoaderWithCacheAPI { cacheEndpoint: (getMetrics
MD5
session)
useLoaderWithCacheAPI { cacheEndpoint: (getMetrics
Hash
session)
, handleResponse
, handleResponse
, mkRequest
, mkRequest
, path: (fst reload /\ path)
, path: (fst reload /\ path)
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Histo.purs
View file @
66f2d55d
...
@@ -6,24 +6,22 @@ import Data.Maybe (Maybe(..))
...
@@ -6,24 +6,22 @@ import Data.Maybe (Maybe(..))
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Prelude
import Gargantext.Components.Charts.Options.ECharts (Options(..), chart, xAxis', yAxis')
import Gargantext.Components.Charts.Options.Series (seriesBarD1)
import Gargantext.Components.Charts.Options.Color (grey)
import Gargantext.Components.Charts.Options.Color (grey)
import Gargantext.Components.Charts.Options.Font (itemStyle, mkTooltip, templateFormatter)
import Gargantext.Components.Charts.Options.Data (dataSerie)
import Gargantext.Components.Charts.Options.Data (dataSerie)
import Gargantext.Components.Charts.Options.ECharts (Options(..), chart, xAxis', yAxis')
import Gargantext.Components.Charts.Options.Font (itemStyle, mkTooltip, templateFormatter)
import Gargantext.Components.Charts.Options.Series (seriesBarD1)
import Gargantext.Components.Nodes.Corpus.Chart.Common (metricsLoadView, metricsWithCacheLoadView)
import Gargantext.Components.Nodes.Corpus.Chart.Common (metricsLoadView, metricsWithCacheLoadView)
import Gargantext.Components.Nodes.Corpus.Chart.Types
import Gargantext.Components.Nodes.Corpus.Chart.Types
import Gargantext.Components.Nodes.Corpus.Chart.Utils as U
import Gargantext.Components.Nodes.Corpus.Chart.Utils as U
import Gargantext.Hooks.Loader (HashedResponse(..))
import Gargantext.Hooks.Loader (HashedResponse(..))
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, get)
import Gargantext.Sessions (Session, get)
import Gargantext.Types (ChartType(..), TabType(..))
import Gargantext.Types (ChartType(..), TabType(..))
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.CacheAPI as GUC
import Reactix as R
import Reactix.DOM.HTML as H
newtype ChartMetrics = ChartMetrics {
newtype ChartMetrics = ChartMetrics {
"data" :: HistoMetrics
"data" :: HistoMetrics
...
@@ -64,14 +62,14 @@ chartOptions (HistoMetrics { dates: dates', count: count'}) = Options
...
@@ -64,14 +62,14 @@ chartOptions (HistoMetrics { dates: dates', count: count'}) = Options
-- getMetrics :: Session -> Tuple Reload (Record Path) -> Aff (HashedResponse HistoMetrics)
-- getMetrics :: Session -> Tuple Reload (Record Path) -> Aff (HashedResponse HistoMetrics)
-- getMetrics session (_ /\ { corpusId, limit, listId, tabType }) = do
-- getMetrics session (_ /\ { corpusId, limit, listId, tabType }) = do
-- HashedResponse {
md5
, value: ChartMetrics ms } <- get session chart
-- HashedResponse {
hash
, value: ChartMetrics ms } <- get session chart
-- pure $ HashedResponse {
md5
, value: ms."data" }
-- pure $ HashedResponse {
hash
, value: ms."data" }
-- where
-- where
-- chart = Chart {chartType: Histo, listId, tabType, limit} (Just corpusId)
-- chart = Chart {chartType: Histo, listId, tabType, limit} (Just corpusId)
getMetrics
MD5
:: Session -> Tuple Reload (Record Path) -> Aff String
getMetrics
Hash
:: Session -> Tuple Reload (Record Path) -> Aff String
getMetrics
MD5
session (_ /\ { corpusId, limit, listId, tabType }) = do
getMetrics
Hash
session (_ /\ { corpusId, limit, listId, tabType }) = do
get session $ Chart
MD5
{ chartType: Histo, listId, tabType } (Just corpusId)
get session $ Chart
Hash
{ chartType: Histo, listId, tabType } (Just corpusId)
chartUrl :: Record Path -> SessionRoute
chartUrl :: Record Path -> SessionRoute
chartUrl { corpusId, limit, listId, tabType } = Chart {chartType: Histo, limit, listId, tabType} (Just corpusId)
chartUrl { corpusId, limit, listId, tabType } = Chart {chartType: Histo, limit, listId, tabType} (Just corpusId)
...
@@ -91,7 +89,7 @@ histoCpt = R.hooksComponent "G.C.N.C.C.H.histo" cpt
...
@@ -91,7 +89,7 @@ histoCpt = R.hooksComponent "G.C.N.C.C.H.histo" cpt
cpt { path, session } _ = do
cpt { path, session } _ = do
reload <- R.useState' 0
reload <- R.useState' 0
pure $ metricsWithCacheLoadView {
pure $ metricsWithCacheLoadView {
getMetrics
MD5
getMetrics
Hash
, handleResponse
, handleResponse
, loaded
, loaded
, mkRequest: mkRequest session
, mkRequest: mkRequest session
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Metrics.purs
View file @
66f2d55d
...
@@ -100,14 +100,14 @@ scatterOptions metrics' = Options
...
@@ -100,14 +100,14 @@ scatterOptions metrics' = Options
-- getMetrics :: Session -> Tuple Reload (Record Path) -> Aff (HashedResponse Loaded)
-- getMetrics :: Session -> Tuple Reload (Record Path) -> Aff (HashedResponse Loaded)
-- getMetrics session (_ /\ { corpusId, limit, listId, tabType }) = do
-- getMetrics session (_ /\ { corpusId, limit, listId, tabType }) = do
-- HashedResponse {
md5
, value: Metrics ms } <- get session metrics'
-- HashedResponse {
hash
, value: Metrics ms } <- get session metrics'
-- pure $ HashedResponse {
md5
, value: ms."data" }
-- pure $ HashedResponse {
hash
, value: ms."data" }
-- where
-- where
-- metrics' = CorpusMetrics {limit, listId, tabType} (Just corpusId)
-- metrics' = CorpusMetrics {limit, listId, tabType} (Just corpusId)
getMetrics
MD5
:: Session -> Tuple Reload (Record Path) -> Aff String
getMetrics
Hash
:: Session -> Tuple Reload (Record Path) -> Aff String
getMetrics
MD5
session (_ /\ { corpusId, listId, tabType }) =
getMetrics
Hash
session (_ /\ { corpusId, listId, tabType }) =
get session $ CorpusMetrics
MD5
{ listId, tabType } (Just corpusId)
get session $ CorpusMetrics
Hash
{ listId, tabType } (Just corpusId)
chartUrl :: Record Path -> SessionRoute
chartUrl :: Record Path -> SessionRoute
chartUrl { corpusId, limit, listId, tabType } = CorpusMetrics { limit, listId, tabType } (Just corpusId)
chartUrl { corpusId, limit, listId, tabType } = CorpusMetrics { limit, listId, tabType } (Just corpusId)
...
@@ -127,7 +127,7 @@ metricsCpt = R.hooksComponent "G.C.N.C.C.M.metrics" cpt
...
@@ -127,7 +127,7 @@ metricsCpt = R.hooksComponent "G.C.N.C.C.M.metrics" cpt
cpt {path, session} _ = do
cpt {path, session} _ = do
reload <- R.useState' 0
reload <- R.useState' 0
pure $ metricsWithCacheLoadView {
pure $ metricsWithCacheLoadView {
getMetrics
MD5
getMetrics
Hash
, handleResponse
, handleResponse
, loaded
, loaded
, mkRequest: mkRequest session
, mkRequest: mkRequest session
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Pie.purs
View file @
66f2d55d
...
@@ -9,24 +9,22 @@ import Data.String (take, joinWith, Pattern(..), split, length)
...
@@ -9,24 +9,22 @@ import Data.String (take, joinWith, Pattern(..), split, length)
import Data.Tuple (Tuple(..))
import Data.Tuple (Tuple(..))
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Effect.Aff (Aff)
import Reactix as R
import Reactix.DOM.HTML as H
import Gargantext.Prelude
import Gargantext.Components.Charts.Options.ECharts (Options(..), chart, xAxis', yAxis')
import Gargantext.Components.Charts.Options.Series (seriesBarD1, seriesPieD1)
import Gargantext.Components.Charts.Options.Color (blue)
import Gargantext.Components.Charts.Options.Color (blue)
import Gargantext.Components.Charts.Options.Font (itemStyle, mkTooltip, templateFormatter)
import Gargantext.Components.Charts.Options.Data (dataSerie)
import Gargantext.Components.Charts.Options.Data (dataSerie)
import Gargantext.Components.Charts.Options.ECharts (Options(..), chart, xAxis', yAxis')
import Gargantext.Components.Charts.Options.Font (itemStyle, mkTooltip, templateFormatter)
import Gargantext.Components.Charts.Options.Series (seriesBarD1, seriesPieD1)
import Gargantext.Components.Nodes.Corpus.Chart.Common (metricsLoadView, metricsWithCacheLoadView)
import Gargantext.Components.Nodes.Corpus.Chart.Common (metricsLoadView, metricsWithCacheLoadView)
import Gargantext.Components.Nodes.Corpus.Chart.Types
import Gargantext.Components.Nodes.Corpus.Chart.Types
import Gargantext.Components.Nodes.Corpus.Chart.Utils as U
import Gargantext.Components.Nodes.Corpus.Chart.Utils as U
import Gargantext.Hooks.Loader (HashedResponse(..))
import Gargantext.Hooks.Loader (HashedResponse(..))
import Gargantext.Prelude
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, get)
import Gargantext.Sessions (Session, get)
import Gargantext.Types (ChartType(..), TabType)
import Gargantext.Types (ChartType(..), TabType)
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.CacheAPI as GUC
import Reactix as R
import Reactix.DOM.HTML as H
newtype ChartMetrics = ChartMetrics {
newtype ChartMetrics = ChartMetrics {
"data" :: HistoMetrics
"data" :: HistoMetrics
...
@@ -84,13 +82,13 @@ chartOptionsPie (HistoMetrics { dates: dates', count: count'}) = Options
...
@@ -84,13 +82,13 @@ chartOptionsPie (HistoMetrics { dates: dates', count: count'}) = Options
-- getMetrics :: Session -> Tuple Reload (Record Path) -> Aff (HashedResponse HistoMetrics)
-- getMetrics :: Session -> Tuple Reload (Record Path) -> Aff (HashedResponse HistoMetrics)
-- getMetrics session (_ /\ { corpusId, limit, listId, tabType }) = do
-- getMetrics session (_ /\ { corpusId, limit, listId, tabType }) = do
-- HashedResponse {
md5
, value: ChartMetrics ms } <- GUC.get session chart --get session chart
-- HashedResponse {
hash
, value: ChartMetrics ms } <- GUC.get session chart --get session chart
-- pure $ HashedResponse {
md5
, value: ms."data" }
-- pure $ HashedResponse {
hash
, value: ms."data" }
-- where chart = Chart {chartType: ChartPie, limit, listId, tabType} (Just corpusId)
-- where chart = Chart {chartType: ChartPie, limit, listId, tabType} (Just corpusId)
getMetrics
MD5
:: Session -> Tuple Reload (Record Path) -> Aff String
getMetrics
Hash
:: Session -> Tuple Reload (Record Path) -> Aff String
getMetrics
MD5
session (_ /\ { corpusId, limit, listId, tabType }) = do
getMetrics
Hash
session (_ /\ { corpusId, limit, listId, tabType }) = do
get session $ Chart
MD5
{ chartType: ChartPie, listId, tabType } (Just corpusId)
get session $ Chart
Hash
{ chartType: ChartPie, listId, tabType } (Just corpusId)
chartUrl :: Record Path -> SessionRoute
chartUrl :: Record Path -> SessionRoute
chartUrl { corpusId, limit, listId, tabType } = Chart {chartType: ChartPie, limit, listId, tabType} (Just corpusId)
chartUrl { corpusId, limit, listId, tabType } = Chart {chartType: ChartPie, limit, listId, tabType} (Just corpusId)
...
@@ -110,7 +108,7 @@ pieCpt = R.hooksComponent "G.C.N.C.C.P.pie" cpt
...
@@ -110,7 +108,7 @@ pieCpt = R.hooksComponent "G.C.N.C.C.P.pie" cpt
cpt { path, session } _ = do
cpt { path, session } _ = do
reload <- R.useState' 0
reload <- R.useState' 0
pure $ metricsWithCacheLoadView {
pure $ metricsWithCacheLoadView {
getMetrics
MD5
getMetrics
Hash
, handleResponse
, handleResponse
, loaded: loadedPie
, loaded: loadedPie
, mkRequest: mkRequest session
, mkRequest: mkRequest session
...
@@ -138,7 +136,7 @@ barCpt = R.hooksComponent "LoadedMetricsBar" cpt
...
@@ -138,7 +136,7 @@ barCpt = R.hooksComponent "LoadedMetricsBar" cpt
reload <- R.useState' 0
reload <- R.useState' 0
--pure $ metricsLoadView {getMetrics, loaded: loadedBar, path, reload, session}
--pure $ metricsLoadView {getMetrics, loaded: loadedBar, path, reload, session}
pure $ metricsWithCacheLoadView {
pure $ metricsWithCacheLoadView {
getMetrics
MD5
getMetrics
Hash
, handleResponse
, handleResponse
, loaded: loadedPie
, loaded: loadedPie
, mkRequest: mkRequest session
, mkRequest: mkRequest session
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Tree.purs
View file @
66f2d55d
...
@@ -55,14 +55,14 @@ scatterOptions nodes = Options
...
@@ -55,14 +55,14 @@ scatterOptions nodes = Options
-- getMetrics :: Session -> Tuple Reload (Record Path) -> Aff (HashedResponse Loaded)
-- getMetrics :: Session -> Tuple Reload (Record Path) -> Aff (HashedResponse Loaded)
-- getMetrics session (_ /\ { corpusId, limit, listId, tabType }) = do
-- getMetrics session (_ /\ { corpusId, limit, listId, tabType }) = do
-- HashedResponse {
md5
, value: Metrics ms } <- GUC.get session chart
-- HashedResponse {
hash
, value: Metrics ms } <- GUC.get session chart
-- pure $ HashedResponse {
md5
, value: ms."data" }
-- pure $ HashedResponse {
hash
, value: ms."data" }
-- where
-- where
-- chart = Chart {chartType : ChartTree, limit, listId, tabType} (Just corpusId)
-- chart = Chart {chartType : ChartTree, limit, listId, tabType} (Just corpusId)
getMetrics
MD5
:: Session -> Tuple Reload (Record Path) -> Aff String
getMetrics
Hash
:: Session -> Tuple Reload (Record Path) -> Aff String
getMetrics
MD5
session (_ /\ { corpusId, limit, listId, tabType }) = do
getMetrics
Hash
session (_ /\ { corpusId, limit, listId, tabType }) = do
get session $ Chart
MD5
{ chartType: ChartTree, listId, tabType } (Just corpusId)
get session $ Chart
Hash
{ chartType: ChartTree, listId, tabType } (Just corpusId)
chartUrl :: Record Path -> SessionRoute
chartUrl :: Record Path -> SessionRoute
chartUrl { corpusId, limit, listId, tabType } = Chart {chartType: ChartTree, limit, listId, tabType} (Just corpusId)
chartUrl { corpusId, limit, listId, tabType } = Chart {chartType: ChartTree, limit, listId, tabType} (Just corpusId)
...
@@ -82,7 +82,7 @@ treeCpt = R.hooksComponent "G.C.N.C.C.T.tree" cpt
...
@@ -82,7 +82,7 @@ treeCpt = R.hooksComponent "G.C.N.C.C.T.tree" cpt
cpt {path, session} _ = do
cpt {path, session} _ = do
reload <- R.useState' 0
reload <- R.useState' 0
pure $ metricsWithCacheLoadView {
pure $ metricsWithCacheLoadView {
getMetrics
MD5
getMetrics
Hash
, handleResponse
, handleResponse
, loaded
, loaded
, mkRequest: mkRequest session
, mkRequest: mkRequest session
...
...
src/Gargantext/Components/Nodes/Texts.purs
View file @
66f2d55d
...
@@ -16,7 +16,6 @@ import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo)
...
@@ -16,7 +16,6 @@ import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo)
import Gargantext.Components.Nodes.Corpus.Types (CorpusData, Hyperdata(..), getCorpusInfo, CorpusInfo(..))
import Gargantext.Components.Nodes.Corpus.Types (CorpusData, Hyperdata(..), getCorpusInfo, CorpusInfo(..))
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Table as Table
import Gargantext.Components.Table as Table
import Gargantext.Hooks.Loader (useLoaderWithCache)
import Gargantext.Ends (Frontends)
import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session)
import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType(..), TabSubType(..), TabType(..))
import Gargantext.Types (CTabNgramType(..), TabSubType(..), TabType(..))
...
...
src/Gargantext/Ends.purs
View file @
66f2d55d
...
@@ -192,9 +192,9 @@ sessionPath (R.CorpusMetrics { listId, limit, tabType} i) =
...
@@ -192,9 +192,9 @@ sessionPath (R.CorpusMetrics { listId, limit, tabType} i) =
<> "?ngrams=" <> show listId
<> "?ngrams=" <> show listId
<> "&ngramsType=" <> showTabType' tabType
<> "&ngramsType=" <> showTabType' tabType
<> maybe "" limitUrl limit
<> maybe "" limitUrl limit
sessionPath (R.CorpusMetrics
MD5
{ listId, tabType} i) =
sessionPath (R.CorpusMetrics
Hash
{ listId, tabType} i) =
sessionPath $ R.NodeAPI Corpus i
sessionPath $ R.NodeAPI Corpus i
$ "metrics/
md5
"
$ "metrics/
hash
"
<> "?ngrams=" <> show listId
<> "?ngrams=" <> show listId
<> "&ngramsType=" <> showTabType' tabType
<> "&ngramsType=" <> showTabType' tabType
-- TODO fix this url path
-- TODO fix this url path
...
@@ -209,10 +209,10 @@ sessionPath (R.Chart {chartType, listId, limit, tabType} i) =
...
@@ -209,10 +209,10 @@ sessionPath (R.Chart {chartType, listId, limit, tabType} i) =
Just li -> "&limit=" <> show li
Just li -> "&limit=" <> show li
Nothing -> ""
Nothing -> ""
-- <> maybe "" limitUrl limit
-- <> maybe "" limitUrl limit
sessionPath (R.Chart
MD5
{ chartType, listId, tabType } i) =
sessionPath (R.Chart
Hash
{ chartType, listId, tabType } i) =
sessionPath $ R.NodeAPI Corpus i
sessionPath $ R.NodeAPI Corpus i
$ show chartType
$ show chartType
<> "/
md5
?ngramsType=" <> showTabType' tabType
<> "/
hash
?ngramsType=" <> showTabType' tabType
<> "&listType=" <> show MapTerm-- <> show listId
<> "&listType=" <> show MapTerm-- <> show listId
<> defaultListAdd listId
<> defaultListAdd listId
-- sessionPath (R.NodeAPI (NodeContact s a i) i) = sessionPath $ "annuaire/" <> show a <> "/contact/" <> show i
-- sessionPath (R.NodeAPI (NodeContact s a i) i) = sessionPath $ "annuaire/" <> show a <> "/contact/" <> show i
...
...
src/Gargantext/Hooks/Loader.purs
View file @
66f2d55d
module Gargantext.Hooks.Loader where
module Gargantext.Hooks.Loader where
import DOM.Simple.Console (log2)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, (.:), (:=), (~>), jsonEmptyObject)
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, (.:), (:=), (~>), jsonEmptyObject)
import Data.Argonaut.Core (stringify)
import Data.Argonaut.Core (stringify)
import Data.Argonaut.Parser (jsonParser)
import Data.Argonaut.Parser (jsonParser)
...
@@ -7,21 +8,18 @@ import Data.Either (Either(..))
...
@@ -7,21 +8,18 @@ import Data.Either (Either(..))
import Data.Maybe (Maybe(..), isJust, maybe)
import Data.Maybe (Maybe(..), isJust, maybe)
import Data.Tuple (fst)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
import Data.Tuple.Nested ((/\))
import DOM.Simple.Console (log2)
import Effect.Aff (Aff, launchAff_, throwError)
import Effect.Aff (Aff, launchAff_, throwError)
import Effect.Class (liftEffect)
import Effect.Class (liftEffect)
import Effect.Exception (error)
import Effect.Exception (error)
import Milkis as M
import Reactix as R
import Web.Storage.Storage as WSS
import Gargantext.Prelude
import Gargantext.Components.LoadingSpinner (loadingSpinner)
import Gargantext.Components.LoadingSpinner (loadingSpinner)
import Gargantext.Ends (class ToUrl, toUrl)
import Gargantext.Ends (class ToUrl, toUrl)
import Gargantext.Prelude
import Gargantext.Utils as GU
import Gargantext.Utils as GU
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.CacheAPI as GUC
import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Reactix as R2
import Milkis as M
import Reactix as R
import Web.Storage.Storage as WSS
useLoader :: forall path st. Eq path
useLoader :: forall path st. Eq path
...
@@ -53,24 +51,24 @@ useLoaderEffect path state@(state' /\ setState) loader = do
...
@@ -53,24 +51,24 @@ useLoaderEffect path state@(state' /\ setState) loader = do
liftEffect $ setState $ const $ Just l
liftEffect $ setState $ const $ Just l
type
MD5
= String
type
Hash
= String
newtype HashedResponse a = HashedResponse {
newtype HashedResponse a = HashedResponse {
md5 :: MD5
hash :: Hash
, value :: a
, value :: a
}
}
instance decodeHashedResponse :: DecodeJson a => DecodeJson (HashedResponse a) where
instance decodeHashedResponse :: DecodeJson a => DecodeJson (HashedResponse a) where
decodeJson json = do
decodeJson json = do
obj <- decodeJson json
obj
<- decodeJson json
md5 <- obj .: "md5
"
hash <- obj .: "hash
"
value <- obj .: "value"
value <- obj .: "value"
pure $ HashedResponse {
md5
, value }
pure $ HashedResponse {
hash
, value }
instance encodeHashedResponse :: EncodeJson a => EncodeJson (HashedResponse a) where
instance encodeHashedResponse :: EncodeJson a => EncodeJson (HashedResponse a) where
encodeJson (HashedResponse {
md5
, value }) = do
encodeJson (HashedResponse {
hash
, value }) = do
"
md5" := encodeJson md5
"
hash" := encodeJson hash
~> "value" := encodeJson value
~> "value" := encodeJson value
~> jsonEmptyObject
~> jsonEmptyObject
...
@@ -81,9 +79,9 @@ useLoaderWithCache :: forall path st. Eq path => DecodeJson st => EncodeJson st
...
@@ -81,9 +79,9 @@ useLoaderWithCache :: forall path st. Eq path => DecodeJson st => EncodeJson st
-> (path -> Aff (HashedResponse st))
-> (path -> Aff (HashedResponse st))
-> (st -> R.Element)
-> (st -> R.Element)
-> R.Hooks R.Element
-> R.Hooks R.Element
useLoaderWithCache path keyFunc
md5
Endpoint loader render = do
useLoaderWithCache path keyFunc
hash
Endpoint loader render = do
state <- R.useState' Nothing
state <- R.useState' Nothing
useCachedLoaderEffect { cacheEndpoint:
md5
Endpoint
useCachedLoaderEffect { cacheEndpoint:
hash
Endpoint
, keyFunc
, keyFunc
, loadRealData: loadRealData state
, loadRealData: loadRealData state
, path
, path
...
@@ -93,11 +91,11 @@ useLoaderWithCache path keyFunc md5Endpoint loader render = do
...
@@ -93,11 +91,11 @@ useLoaderWithCache path keyFunc md5Endpoint loader render = do
loadRealData :: R.State (Maybe st) -> String -> String -> WSS.Storage -> Aff Unit
loadRealData :: R.State (Maybe st) -> String -> String -> WSS.Storage -> Aff Unit
loadRealData (_ /\ setState) key keyCache localStorage = do
loadRealData (_ /\ setState) key keyCache localStorage = do
--R2.affEffect "G.H.Loader.useCachedLoaderEffect" $ do
--R2.affEffect "G.H.Loader.useCachedLoaderEffect" $ do
HashedResponse {
md5
, value: l } <- loader path
HashedResponse {
hash
, value: l } <- loader path
liftEffect $ do
liftEffect $ do
let value = stringify $ encodeJson l
let value = stringify $ encodeJson l
WSS.setItem key value localStorage
WSS.setItem key value localStorage
WSS.setItem keyCache
md5
localStorage
WSS.setItem keyCache
hash
localStorage
setState $ const $ Just l
setState $ const $ Just l
pure unit
pure unit
...
@@ -159,7 +157,7 @@ useCachedLoaderEffect { cacheEndpoint, keyFunc, loadRealData, path, state: state
...
@@ -159,7 +157,7 @@ useCachedLoaderEffect { cacheEndpoint, keyFunc, loadRealData, path, state: state
type LoaderWithCacheAPIProps path res ret = (
type LoaderWithCacheAPIProps path res ret = (
cacheEndpoint :: path -> Aff
MD5
cacheEndpoint :: path -> Aff
Hash
, handleResponse :: HashedResponse res -> ret
, handleResponse :: HashedResponse res -> ret
, mkRequest :: path -> GUC.Request
, mkRequest :: path -> GUC.Request
, path :: path
, path :: path
...
@@ -180,7 +178,7 @@ useLoaderWithCacheAPI { cacheEndpoint, handleResponse, mkRequest, path, renderer
...
@@ -180,7 +178,7 @@ useLoaderWithCacheAPI { cacheEndpoint, handleResponse, mkRequest, path, renderer
pure $ maybe (loadingSpinner {}) renderer (fst state)
pure $ maybe (loadingSpinner {}) renderer (fst state)
type LoaderWithCacheAPIEffectProps path res ret = (
type LoaderWithCacheAPIEffectProps path res ret = (
cacheEndpoint :: path -> Aff
MD5
cacheEndpoint :: path -> Aff
Hash
, handleResponse :: HashedResponse res -> ret
, handleResponse :: HashedResponse res -> ret
, mkRequest :: path -> GUC.Request
, mkRequest :: path -> GUC.Request
, path :: path
, path :: path
...
@@ -205,19 +203,19 @@ useCachedAPILoaderEffect { cacheEndpoint
...
@@ -205,19 +203,19 @@ useCachedAPILoaderEffect { cacheEndpoint
let cacheName = "cache-api-loader"
let cacheName = "cache-api-loader"
let req = mkRequest path
let req = mkRequest path
let keyCache = "cached-api-
md5
-" <> (show path)
let keyCache = "cached-api-
hash
-" <> (show path)
-- log2 "[useCachedLoader] mState" mState
-- log2 "[useCachedLoader] mState" mState
launchAff_ $ do
launchAff_ $ do
cache <- GUC.openCache $ GUC.CacheName cacheName
cache <- GUC.openCache $ GUC.CacheName cacheName
-- TODO Parallelize?
-- TODO Parallelize?
hr@(HashedResponse {
md5
, value }) <- GUC.cachedJson cache req
hr@(HashedResponse {
hash
, value }) <- GUC.cachedJson cache req
cacheReal <- cacheEndpoint path
cacheReal <- cacheEndpoint path
val <- if
md5
== cacheReal then
val <- if
hash
== cacheReal then
pure hr
pure hr
else do
else do
_ <- GUC.delete cache req
_ <- GUC.delete cache req
hr@(HashedResponse {
md5
, value }) <- GUC.cachedJson cache req
hr@(HashedResponse {
hash
, value }) <- GUC.cachedJson cache req
if
md5
== cacheReal then
if
hash
== cacheReal then
pure hr
pure hr
else
else
throwError $ error $ "Fetched clean cache but hashes don't match"
throwError $ error $ "Fetched clean cache but hashes don't match"
...
...
src/Gargantext/Routes.purs
View file @
66f2d55d
...
@@ -48,9 +48,9 @@ data SessionRoute
...
@@ -48,9 +48,9 @@ data SessionRoute
| ListDocument (Maybe ListId) (Maybe Id)
| ListDocument (Maybe ListId) (Maybe Id)
| Search SearchOpts (Maybe Id)
| Search SearchOpts (Maybe Id)
| CorpusMetrics CorpusMetricOpts (Maybe Id)
| CorpusMetrics CorpusMetricOpts (Maybe Id)
| CorpusMetrics
MD5
{ listId :: ListId, tabType :: TabType } (Maybe Id)
| CorpusMetrics
Hash
{ listId :: ListId, tabType :: TabType } (Maybe Id)
| Chart ChartOpts (Maybe Id)
| Chart ChartOpts (Maybe Id)
| Chart
MD5
{ chartType :: ChartType, listId :: ListId, tabType :: TabType } (Maybe Id)
| Chart
Hash
{ chartType :: ChartType, listId :: ListId, tabType :: TabType } (Maybe Id)
instance showAppRoute :: Show AppRoute where
instance showAppRoute :: Show AppRoute where
show Home = "Home"
show Home = "Home"
...
...
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