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

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