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
63f6ee37
Commit
63f6ee37
authored
Jul 07, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[list] list and ngrams cache fixes
list= is an optional parameter, reflected this in the Maybe type.
parent
0630ea02
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
71 additions
and
38 deletions
+71
-38
DocsTable.purs
src/Gargantext/Components/DocsTable.purs
+37
-16
NgramsTable.purs
src/Gargantext/Components/NgramsTable.purs
+0
-6
Loader.purs
src/Gargantext/Components/NgramsTable/Loader.purs
+2
-4
Histo.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Histo.purs
+6
-2
Pie.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Pie.purs
+6
-2
Tree.purs
src/Gargantext/Components/Nodes/Corpus/Chart/Tree.purs
+6
-2
Texts.purs
src/Gargantext/Components/Nodes/Texts.purs
+2
-1
Ends.purs
src/Gargantext/Ends.purs
+10
-3
Routes.purs
src/Gargantext/Routes.purs
+1
-1
Types.purs
src/Gargantext/Types.purs
+1
-1
No files found.
src/Gargantext/Components/DocsTable.purs
View file @
63f6ee37
...
...
@@ -32,13 +32,14 @@ import Gargantext.Prelude
import Gargantext.Components.Table as T
import Gargantext.Ends (Frontends, url)
import Gargantext.Hooks.Loader (useLoader, useLoaderWithCache, HashedResponse(..))
import Gargantext.Hooks.Loader (useLoader, useLoaderWithCache,
useLoaderWithCacheAPI,
HashedResponse(..))
import Gargantext.Utils.List (sortWith) as L
import Gargantext.Utils.Reactix as R2
import Gargantext.Routes as Routes
import Gargantext.Routes (SessionRoute(NodeAPI))
import Gargantext.Sessions (Session, sessionId, get, post, delete, put)
import Gargantext.Types (NodeType(..), OrderBy(..), TableResult, TabType, TabPostQuery(..), AffTableResult, showTabType')
import Gargantext.Utils.CacheAPI as GUC
------------------------------------------------------------------------
data Category = Trash | UnRead | Checked | Topic | Favorite
...
...
@@ -370,17 +371,6 @@ loadPage session { corpusId, listId, nodeId, query, tabType } = do
else
Tuple res.count docs
pure $ HashedResponse { md5, value: ret }
where
res2corpus :: Response -> DocumentsView
res2corpus (Response r) =
DocumentsView { _id : r.cid
, url : ""
, date : (\(Hyperdata hr) -> hr.pub_year) r.hyperdata
, title : (\(Hyperdata hr) -> hr.title) r.hyperdata
, source : (\(Hyperdata hr) -> hr.source) r.hyperdata
, category : r.category
, ngramCount : r.ngramCount
}
getPageMD5 :: Session -> PageParams -> Aff String
getPageMD5 session { corpusId, listId, nodeId, query, tabType } = do
...
...
@@ -396,6 +386,17 @@ convOrderBy (Just (T.ASC (T.ColumnName "Source"))) = Just SourceAsc
convOrderBy (Just (T.DESC (T.ColumnName "Source"))) = Just SourceDesc
convOrderBy _ = Nothing
res2corpus :: Response -> DocumentsView
res2corpus (Response r) =
DocumentsView { _id : r.cid
, url : ""
, date : (\(Hyperdata hr) -> hr.pub_year) r.hyperdata
, title : (\(Hyperdata hr) -> hr.title) r.hyperdata
, source : (\(Hyperdata hr) -> hr.source) r.hyperdata
, category : r.category
, ngramCount : r.ngramCount
}
pageLayout :: Record PageLayoutProps -> R.Element
pageLayout props = R.createElement pageLayoutCpt props []
...
...
@@ -403,14 +404,34 @@ pageLayoutCpt :: R.Component PageLayoutProps
pageLayoutCpt = R.hooksComponent "G.C.DocsTable.pageLayout" cpt where
cpt props@{frontends, session, nodeId, listId, corpusId, tabType, query, params} _ =
-- useLoader path (loadPage session) paint
useLoaderWithCache path keyFunc (getPageMD5 session) (loadPage session) paint
--useLoaderWithCache path keyFunc (getPageMD5 session) (loadPage session) paint
useLoaderWithCacheAPI {
cacheEndpoint: getPageMD5 session
, handleResponse
, mkRequest
, path
, renderer: paint
}
where
path = {
nodeId, listId, corpusId, tabType, query, params
}
path = {
corpusId, listId, nodeId, params, query, tabType
}
paint (Tuple count docs) = page params (newProps count) docs
newProps count = props { totalRecords = count }
keyFunc { corpusId, listId, nodeId, tabType } =
"page-" <> (show tabType) <> "-" <> (show corpusId) <> "-" <> (show nodeId) <> "-" <> (show listId)
-- keyFunc { corpusId, listId, nodeId, tabType } =
-- "page-" <> (show tabType) <> "-" <> (show corpusId) <> "-" <> (show nodeId) <> "-" <> (show listId)
mkRequest :: PageParams -> GUC.Request
mkRequest p@{ listId, nodeId, tabType } =
GUC.makeGetRequest session $ NodeAPI Node (Just nodeId) $ "table" <> "?tabType=" <> (showTabType' tabType) <> "&list=" <> (show listId)
handleResponse :: HashedResponse (TableResult Response) -> Tuple Int (Array DocumentsView)
handleResponse (HashedResponse { md5, value: res }) = ret
where
docs = res2corpus <$> res.docs
ret = if mock then
--Tuple 0 (take limit $ drop offset sampleData)
Tuple 0 sampleData
else
Tuple res.count docs
type PageProps = (
documents :: Array DocumentsView
...
...
src/Gargantext/Components/NgramsTable.purs
View file @
63f6ee37
...
...
@@ -29,7 +29,6 @@ import Reactix.DOM.HTML as H
import Unsafe.Coerce (unsafeCoerce)
import Gargantext.Components.AutoUpdate (autoUpdateElt)
import Gargantext.Components.LoadingSpinner (loadingSpinner)
import Gargantext.Components.NgramsTable.Components as NTC
import Gargantext.Components.NgramsTable.Core
import Gargantext.Components.NgramsTable.Loader (useLoaderWithCacheAPI)
...
...
@@ -505,11 +504,6 @@ mainNgramsTableCpt = R.hooksComponent "G.C.NT.mainNgramsTable" cpt
, renderer: \versioned -> mainNgramsTablePaint { path, tabNgramType, versioned, withAutoUpdate }
}
-- useLoaderWithVersionCache (pathNoLimit path) (keyFunc props) (versionEndpoint props) loadNgramsTable \versioned -> do
-- mainNgramsTablePaint { path, tabNgramType, versioned, withAutoUpdate }
-- keyFunc { defaultListId, nodeId, tabType } _ =
-- "ngrams-table-" <> (show tabType) <> "-" <> (show nodeId) <> "-" <> (show defaultListId)
versionEndpoint :: Record MainNgramsTableProps -> PageParams -> Aff Version
versionEndpoint { defaultListId, nodeId, session, tabType } _ = get session $ R.GetNgramsTableVersion { listId: defaultListId, tabType } (Just nodeId)
...
...
src/Gargantext/Components/NgramsTable/Loader.purs
View file @
63f6ee37
module Gargantext.Components.NgramsTable.Loader where
import Data.Argonaut (class DecodeJson, class EncodeJson, decodeJson, encodeJson, (.:), (:=), (~>), jsonEmptyObject)
import Data.Argonaut.Core (stringify)
import Data.Argonaut (class DecodeJson)
import Data.Maybe (Maybe(..), maybe, isJust)
import Data.Tuple (fst)
import Data.Tuple.Nested ((/\))
...
...
@@ -9,8 +8,7 @@ import Effect.Aff (Aff, launchAff_, throwError)
import Effect.Class (liftEffect)
import Effect.Exception (error)
import Reactix as R
import Web.Storage.Storage as WSS
import Gargantext.Prelude
import Gargantext.Components.LoadingSpinner (loadingSpinner)
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Histo.purs
View file @
63f6ee37
...
...
@@ -71,10 +71,14 @@ chartOptions (HistoMetrics { dates: dates', count: count'}) = Options
getMetricsMD5 :: Session -> Tuple Reload (Record Path) -> Aff String
getMetricsMD5 session (_ /\ { corpusId, limit, listId, tabType }) = do
get session $ ChartMD5 { chartType: Histo, listId, tabType } (Just corpusId)
get session $ ChartMD5 { chartType: Histo, listId: mListId, tabType } (Just corpusId)
where
mListId = if listId == 0 then Nothing else (Just listId)
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: mListId, tabType} (Just corpusId)
where
mListId = if listId == 0 then Nothing else (Just listId)
handleResponse :: HashedResponse ChartMetrics -> HistoMetrics
handleResponse (HashedResponse { value: ChartMetrics ms }) = ms."data"
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Pie.purs
View file @
63f6ee37
...
...
@@ -90,10 +90,14 @@ chartOptionsPie (HistoMetrics { dates: dates', count: count'}) = Options
getMetricsMD5 :: Session -> Tuple Reload (Record Path) -> Aff String
getMetricsMD5 session (_ /\ { corpusId, limit, listId, tabType }) = do
get session $ ChartMD5 { chartType: ChartPie, listId, tabType } (Just corpusId)
get session $ ChartMD5 { chartType: ChartPie, listId: mListId, tabType } (Just corpusId)
where
mListId = if listId == 0 then Nothing else (Just listId)
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: mListId, tabType} (Just corpusId)
where
mListId = if listId == 0 then Nothing else (Just listId)
handleResponse :: HashedResponse ChartMetrics -> HistoMetrics
handleResponse (HashedResponse { value: ChartMetrics ms }) = ms."data"
...
...
src/Gargantext/Components/Nodes/Corpus/Chart/Tree.purs
View file @
63f6ee37
...
...
@@ -62,10 +62,14 @@ scatterOptions nodes = Options
getMetricsMD5 :: Session -> Tuple Reload (Record Path) -> Aff String
getMetricsMD5 session (_ /\ { corpusId, limit, listId, tabType }) = do
get session $ ChartMD5 { chartType: ChartTree, listId, tabType } (Just corpusId)
get session $ ChartMD5 { chartType: ChartTree, listId: mListId, tabType } (Just corpusId)
where
mListId = if listId == 0 then Nothing else (Just listId)
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: mListId, tabType} (Just corpusId)
where
mListId = if listId == 0 then Nothing else (Just listId)
handleResponse :: HashedResponse Metrics -> Loaded
handleResponse (HashedResponse { value: Metrics ms }) = ms."data"
...
...
src/Gargantext/Components/Nodes/Texts.purs
View file @
63f6ee37
...
...
@@ -72,7 +72,8 @@ tabsCpt = R.hooksComponent "G.C.Nodes.Texts.tabs" cpt
docView' tabType = docView { frontends, session, corpusId, corpusData, tabType }
docs = R.fragment [ docsHisto, docView' TabDocs ]
docsHisto = histo { path, session }
where path = { corpusId, listId: 0, limit: Nothing, tabType: TabCorpus TabDocs }
where
path = { corpusId, listId: 0, limit: Nothing, tabType: TabCorpus TabDocs }
moreLikeFav = docView' TabMoreLikeFav
moreLikeTrash = docView' TabMoreLikeTrash
trash = docView' TabTrash
...
...
src/Gargantext/Ends.purs
View file @
63f6ee37
...
...
@@ -197,13 +197,16 @@ sessionPath (R.CorpusMetricsMD5 { listId, tabType} i) =
<> "?ngrams=" <> show listId
<> "&ngramsType=" <> showTabType' tabType
-- TODO fix this url path
sessionPath (R.Chart {chartType, li
stId, limit
, tabType} i) =
sessionPath (R.Chart {chartType, li
mit, listId
, tabType} i) =
sessionPath $ R.NodeAPI Corpus i
$ show chartType
<> "?ngramsType=" <> showTabType' tabType
<> "&listType=MapTerm" -- <> show listId
<>
"&list=" <> show listId
<>
listPath
where
listPath = case listId of
Just li -> "&list=" <> show li
Nothing -> ""
limitPath = case limit of
Just li -> "&limit=" <> show li
Nothing -> ""
...
...
@@ -213,7 +216,11 @@ sessionPath (R.ChartMD5 { chartType, listId, tabType } i) =
$ show chartType
<> "/md5?ngramsType=" <> showTabType' tabType
<> "&listType=GraphTerm" -- <> show listId
<> "&list=" <> show listId
<> listPath
where
listPath = case listId of
Just li -> "&list=" <> show li
Nothing -> ""
-- sessionPath (R.NodeAPI (NodeContact s a i) i) = sessionPath $ "annuaire/" <> show a <> "/contact/" <> show i
------- misc routing stuff
...
...
src/Gargantext/Routes.purs
View file @
63f6ee37
...
...
@@ -50,7 +50,7 @@ data SessionRoute
| CorpusMetrics CorpusMetricOpts (Maybe Id)
| CorpusMetricsMD5 { listId :: ListId, tabType :: TabType } (Maybe Id)
| Chart ChartOpts (Maybe Id)
| ChartMD5 { chartType :: ChartType, listId :: ListId, tabType :: TabType } (Maybe Id)
| ChartMD5 { chartType :: ChartType, listId ::
Maybe
ListId, tabType :: TabType } (Maybe Id)
instance showAppRoute :: Show AppRoute where
show Home = "Home"
...
...
src/Gargantext/Types.purs
View file @
63f6ee37
...
...
@@ -346,8 +346,8 @@ type CorpusMetricOpts =
type ChartOpts =
{ chartType :: ChartType
, listId :: ListId
, limit :: Maybe Limit
, listId :: Maybe ListId
, tabType :: TabType
}
...
...
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