Commit 0261a896 authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge branch 'dev-doc-table-optimization' of...

Merge branch 'dev-doc-table-optimization' of ssh://gitlab.iscpif.fr:20022/gargantext/purescript-gargantext into dev-merge
parents 4ee085b6 fc60ff0a
This diff is collapsed.
......@@ -6,6 +6,7 @@ import Data.Tuple.Nested ((/\))
import Effect.Aff (Aff)
import Effect.Class (liftEffect)
import Reactix as R
import Gargantext.Utils.Reactix as R2
import Gargantext.Components.LoadingSpinner (loadingSpinner)
......
......@@ -34,7 +34,7 @@ import Gargantext.Components.NgramsTable.Components as NTC
import Gargantext.Components.NgramsTable.Core
import Gargantext.Components.NgramsTable.Loader (useLoaderWithVersionCache)
import Gargantext.Components.Table as T
import Gargantext.Hooks.Loader (useLoader)
import Gargantext.Hooks.Loader (useLoaderWithCache)
import Gargantext.Prelude (class Show, Unit, bind, const, discard, identity, map, mempty, not, pure, show, unit, (#), ($), (&&), (/=), (<$>), (<<<), (<>), (=<<), (==), (||), read)
import Gargantext.Routes as R
import Gargantext.Sessions (Session, get)
......@@ -499,15 +499,6 @@ mainNgramsTableCpt = R.hooksComponent "G.C.NT.mainNgramsTable" cpt
useLoaderWithVersionCache (pathNoLimit path) (keyFunc props) (versionEndpoint props) loadNgramsTable \versioned -> do
mainNgramsTablePaint { path, tabNgramType, versioned, withAutoUpdate }
-- useLoaderWithVersionCache path (keyFunc props) (versionEndpoint props) loadNgramsTableAll \loaded -> do
-- useLoader path loadNgramsTableAll \loaded -> do
-- case Map.lookup tabType loaded of
-- Just (versioned :: VersionedNgramsTable) ->
-- mainNgramsTablePaint {path, tabNgramType, versioned, withAutoUpdate}
-- Nothing -> loadingSpinner {}
-- useLoader (pathNoLimit path) loadNgramsTable \versioned -> do
-- mainNgramsTablePaint { path, tabNgramType, versioned, withAutoUpdate }
keyFunc { defaultListId, nodeId, tabType } _ =
"ngrams-table-" <> (show tabType) <> "-" <> (show nodeId) <> "-" <> (show defaultListId)
......
......@@ -16,6 +16,7 @@ import Gargantext.Components.Nodes.Corpus.Chart.Histo (histo)
import Gargantext.Components.Nodes.Corpus.Types (CorpusData, Hyperdata(..), getCorpusInfo, CorpusInfo(..))
import Gargantext.Components.Tab as Tab
import Gargantext.Components.Table as Table
import Gargantext.Hooks.Loader (useLoaderWithCache)
import Gargantext.Ends (Frontends)
import Gargantext.Sessions (Session)
import Gargantext.Types (CTabNgramType(..), TabSubType(..), TabType(..))
......
......@@ -442,6 +442,39 @@ data TabSubType a = TabDocs | TabNgramType a | TabTrash | TabMoreLikeFav | TabMo
derive instance eqTabSubType :: Eq a => Eq (TabSubType a)
derive instance ordTabSubType :: Ord a => Ord (TabSubType a)
{- instance encodeTabSubType a :: EncodeJson a => EncodeJson (TabSubType a) where
encodeJson TabDocs =
"type" := "TabDocs"
~> "data" := Nothing
~> jsonEmptyObject
encodeJson (TabNgramType a) =
"type" := "TabNgramType"
~> "data" := encodeJson a
~> jsonEmptyObject
encodeJson TabTrash =
"type" := "TabTrash"
~> "data" := Nothing
~> jsonEmptyObject
encodeJson TabMoreLikeFav =
"type" := "TabMoreLikeFav"
~> "data" := Nothing
~> jsonEmptyObject
encodeJson TabMoreLikeTrash =
"type" := "TabMoreLikeTrash"
~> "data" := Nothing
~> jsonEmptyObject
instance decodeTabSubType a :: DecodeJson a => DecodeJson (TabSubType a) where
decodeJson j = do
obj <- decodeJson j
typ <- obj .: "type"
dat <- obj .: "data"
case typ of
"TabDocs" -> TabDocs
"TabNgramType" -> TabNgramType dat
"TabTrash" -> TabTrash
"TabMoreLikeFav" -> TabMoreLikeFav
"TabMoreLikeTrash" -> TabMoreLikeTrash
_ -> Left ("Unknown type '" <> typ <> "'") -}
instance showTabSubType :: Show a => Show (TabSubType a) where
show TabDocs = "Docs"
......@@ -455,13 +488,34 @@ data TabType
| TabPairing (TabSubType PTabNgramType)
| TabDocument (TabSubType CTabNgramType)
derive instance genericTabType :: Generic TabType _
derive instance eqTabType :: Eq TabType
derive instance ordTabType :: Ord TabType
derive instance genericTabType :: Generic TabType _
instance showTabType :: Show TabType where
show = genericShow
{- instance encodeTabType :: EncodeJson TabType where
encodeJson (TabCorpus d) =
"type" := "TabCorpus"
~> "data" := encodeJson d
~> jsonEmptyObject
encodeJson (TabDocument d) =
"type" := "TabDocument"
~> "data" := encodeJson d
~> jsonEmptyObject
encodeJson (TabPairing d) =
"type" := "TabPairing"
~> "data" := encodeJson d
~> jsonEmptyObject
instance decodeTabType :: DecodeJson TabType where
decodeJson j = do
obj <- decodeJson j
typ <- obj .: "type"
dat <- obj .: "data"
case typ of
"TabCorpus" -> TabCorpus dat
"TabDocument" -> TabDocument dat
"TabPairing" -> TabPairing dat
_ -> Left ("Unknown type '" <> typ <> "'") -}
type TableResult a = {count :: Int, docs :: Array a}
type AffTableResult a = Aff (TableResult a)
......
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