[refactor] some small refactoring of G.C.D.API function

parent 6cf1f270
Pipeline #4635 canceled with stage
......@@ -6,13 +6,16 @@ import Gargantext.Prelude
import Data.Either (Either(..))
import Data.Maybe (Maybe(..))
import Gargantext.Components.Document.Types (DocPath, LoadedData, NodeDocument)
import Gargantext.Core.NgramsTable.Functions (loadNgramsTable)
import Gargantext.Components.Document.Types (DocPath, NgramsPath, LoadedData, NodeDocument)
import Gargantext.Core.NgramsTable.Functions as NTFunctions
import Gargantext.Core.NgramsTable.Types (VersionedNgramsTable)
import Gargantext.Components.Search (SearchType(..))
import Gargantext.Config.REST (AffRESTError)
import Gargantext.Routes (SessionRoute(..))
import Gargantext.Sessions (Session, get)
import Gargantext.Types (NodeType(..), ScoreType(..))
loadDocument :: Session -> Int -> AffRESTError NodeDocument
loadDocument session nodeId = get session $ NodeAPI Context (Just nodeId) ""
......@@ -22,7 +25,12 @@ loadData { listIds, nodeId, session, tabType } = do
case eDocument of
Left err -> pure $ Left err
Right document -> do
eNgramsTable <- loadNgramsTable
eNgramsTable <- loadNgramsTable { listIds, nodeId, session, tabType }
pure $ (\ngramsTable -> { document, ngramsTable }) <$> eNgramsTable
loadNgramsTable :: NgramsPath -> AffRESTError VersionedNgramsTable
loadNgramsTable { listIds, nodeId, session, tabType } =
NTFunctions.loadNgramsTable
{ listIds
, nodeId
, params: { offset : 0, limit : 100, orderBy: Nothing, searchType: SearchDoc}
......@@ -33,4 +41,3 @@ loadData { listIds, nodeId, session, tabType } = do
, termListFilter: Nothing
, termSizeFilter: Nothing
}
pure $ (\ngramsTable -> { document, ngramsTable }) <$> eNgramsTable
......@@ -20,6 +20,13 @@ type DocPath = {
, tabType :: TabType
}
type NgramsPath = {
listIds :: Array ListId
, nodeId :: NodeID
, session :: Session
, tabType :: TabType
}
type NodeDocument = NodePoly Document
type LoadedData =
......
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