[refactor] some more Cmd refactoring + test fixes

parent 2ed7d1de
Pipeline #5243 passed with stages
in 57 minutes and 29 seconds
......@@ -185,12 +185,12 @@ getChart cId _start _end maybeListId tabType = do
pure $ constructHashedResponse chart
updateChart :: HasNodeError err =>
CorpusId
-> Maybe ListId
-> TabType
-> Maybe Limit
-> DBCmd err ()
updateChart :: HasNodeError err
=> CorpusId
-> Maybe ListId
-> TabType
-> Maybe Limit
-> DBCmd err ()
updateChart cId maybeListId tabType maybeLimit = do
listId <- case maybeListId of
Just lid -> pure lid
......@@ -202,12 +202,12 @@ updateChart cId maybeListId tabType maybeLimit = do
_ <- updateChart' cId listId tabType maybeLimit
pure ()
updateChart' :: HasNodeError err =>
CorpusId
-> ListId
-> TabType
-> Maybe Limit
-> DBCmd err (ChartMetrics Histo)
updateChart' :: HasNodeError err
=> CorpusId
-> ListId
-> TabType
-> Maybe Limit
-> DBCmd err (ChartMetrics Histo)
updateChart' cId listId tabType _maybeLimit = do
node <- getNodeWith listId (Proxy :: Proxy HyperdataList)
let hl = node ^. node_hyperdata
......@@ -267,7 +267,7 @@ getPie cId _start _end maybeListId tabType = do
chart <- case mChart of
Just chart -> pure chart
Nothing -> do
updatePie' cId maybeListId tabType Nothing
updatePie' cId listId tabType Nothing
pure $ constructHashedResponse chart
......@@ -278,23 +278,23 @@ updatePie :: HasNodeStory env err m
-> Maybe Limit
-> m ()
updatePie cId maybeListId tabType maybeLimit = do
listId <- case maybeListId of
Just lid -> pure lid
Nothing -> defaultList cId
printDebug "[updatePie] cId" cId
printDebug "[updatePie] maybeListId" maybeListId
printDebug "[updatePie] tabType" tabType
printDebug "[updatePie] maybeLimit" maybeLimit
_ <- updatePie' cId maybeListId tabType maybeLimit
_ <- updatePie' cId listId tabType maybeLimit
pure ()
updatePie' :: (HasNodeStory env err m, HasNodeError err)
=> CorpusId
-> Maybe ListId
-> ListId
-> TabType
-> Maybe Limit
-> m (ChartMetrics Histo)
updatePie' cId maybeListId tabType _maybeLimit = do
listId <- case maybeListId of
Just lid -> pure lid
Nothing -> defaultList cId
updatePie' cId listId tabType _maybeLimit = do
node <- getNodeWith listId (Proxy :: Proxy HyperdataList)
let hl = node ^. node_hyperdata
pieMap = hl ^. hl_pie
......
This diff is collapsed.
......@@ -36,7 +36,7 @@ import qualified Data.Text as Text
------------------------------------------------------------------------
getNgramsList :: HasNodeStory env err m
=> ListId -> m NgramsList
=> ListId -> m NgramsList
getNgramsList lId = fromList
<$> zip ngramsTypes
<$> mapM (getNgramsTableMap lId) ngramsTypes
......
......@@ -16,24 +16,21 @@ Main exports of Gargantext:
module Gargantext.API.Node.Corpus.Export
where
import Data.HashMap.Strict qualified as HashMap
import Data.List qualified as List
import Data.Map.Strict (Map)
import Data.Map.Strict qualified as Map
import Data.Maybe (fromMaybe)
import Data.Set (Set)
import Data.Set qualified as Set
import Data.Text (Text, pack)
import qualified Data.List as List
import qualified Data.Map.Strict as Map
import qualified Data.Set as Set
import qualified Data.HashMap.Strict as HashMap
import Servant (Headers, Header, addHeader)
import Gargantext.API.Node.Corpus.Export.Types
import qualified Gargantext.API.Node.Document.Export.Types as DocumentExport
import Gargantext.API.Ngrams.Types
import Gargantext.API.Ngrams.Tools (filterListWithRoot, mapTermListRoot, getRepo)
import Gargantext.API.Ngrams.Types
import Gargantext.API.Node.Corpus.Export.Types
import Gargantext.API.Node.Document.Export.Types qualified as DocumentExport
import Gargantext.API.Prelude (GargNoServer)
import Gargantext.Prelude.Crypto.Hash (hash)
import Gargantext.Core.Types
import Gargantext.Core.NodeStory
import Gargantext.Core.Types
import Gargantext.Database.Action.Metrics.NgramsByContext (getNgramsByContextOnlyUser)
import Gargantext.Database.Admin.Config (userMaster)
import Gargantext.Database.Admin.Types.Hyperdata (HyperdataDocument(..))
......@@ -42,9 +39,11 @@ import Gargantext.Database.Query.Table.Node
import Gargantext.Database.Query.Table.Node.Error (HasNodeError)
import Gargantext.Database.Query.Table.Node.Select (selectNodesWithUsername)
import Gargantext.Database.Query.Table.NodeContext (selectDocNodes)
import Gargantext.Database.Schema.Ngrams (NgramsType(..))
import Gargantext.Database.Schema.Context (_context_id, _context_hyperdata)
import Gargantext.Database.Schema.Ngrams (NgramsType(..))
import Gargantext.Prelude
import Gargantext.Prelude.Crypto.Hash (hash)
import Servant (Headers, Header, addHeader)
--------------------------------------------------
-- | Hashes are ordered by Set
......
......@@ -31,7 +31,7 @@ import Gargantext.Database.Admin.Types.Hyperdata.Corpus (HyperdataCorpus)
import Gargantext.Database.Admin.Types.Hyperdata.Document (HyperdataDocument(..))
import Gargantext.Database.Admin.Types.Node (CorpusId, ListId, NodeType(NodeTexts))
import Gargantext.Database.Prelude (hasConfig)
import Gargantext.Database.Query.Table.Node (defaultListMaybe, getOrMkList)
import Gargantext.Database.Query.Table.Node (getOrMkList)
import Gargantext.Database.Query.Table.Node (insertDefaultNodeIfNotExists)
import Gargantext.Database.Query.Table.Node.Error (HasNodeError)
import Gargantext.Database.Query.Tree.Error (HasTreeError)
......@@ -160,12 +160,12 @@ triggerSearxSearch :: ( MonadBase IO m
, HasTreeError err
, HasInvalidError err
, MonadJobStatus m )
=> User
-> CorpusId
-> API.RawQuery
-> Lang
-> JobHandle m
-> m ()
=> User
-> CorpusId
-> API.RawQuery
-> Lang
-> JobHandle m
-> m ()
triggerSearxSearch user cId q l jobHandle = do
userId <- getUserId user
......@@ -181,12 +181,7 @@ triggerSearxSearch user cId q l jobHandle = do
uId <- getUserId user
let surl = _gc_frame_searx_url cfg
-- printDebug "[triggerSearxSearch] surl" surl
mListId <- defaultListMaybe cId
listId <- case mListId of
Nothing -> do
listId <- getOrMkList cId uId
pure listId
Just listId -> pure listId
listId <- getOrMkList cId uId
-- printDebug "[triggerSearxSearch] listId" listId
......
......@@ -281,11 +281,14 @@ type GraphVersionsAPI = Summary "Graph versions"
graphVersionsAPI :: UserId -> NodeId -> GargServer GraphVersionsAPI
graphVersionsAPI u n =
graphVersions 0 n
graphVersions u n
:<|> recomputeVersions u n
graphVersions :: Int -> NodeId -> GargNoServer GraphVersions
graphVersions n nId = do
graphVersions :: (HasNodeStory env err m)
=> UserId
-> NodeId
-> m GraphVersions
graphVersions u nId = do
nodeGraph <- getNodeWith nId (Proxy :: Proxy HyperdataGraph)
let
graph = nodeGraph
......@@ -302,21 +305,14 @@ graphVersions n nId = do
mcId <- getClosestParentIdByType nId NodeCorpus
let cId = maybe (panic "[G.V.G.API] Node has no parent") identity mcId
maybeListId <- defaultListMaybe cId
case maybeListId of
Nothing -> if n <= 2
then graphVersions (n+1) cId
else panic "[G.V.G.API] list not found after iterations"
Just listId -> do
repo <- getRepo [listId]
let v = repo ^. unNodeStory . at listId . _Just . a_version
-- printDebug "graphVersions" v
listId <- getOrMkList cId u
repo <- getRepo [listId]
let v = repo ^. unNodeStory . at listId . _Just . a_version
-- printDebug "graphVersions" v
pure $ GraphVersions { gv_graph = listVersion
, gv_repo = v }
pure $ GraphVersions { gv_graph = listVersion
, gv_repo = v }
--recomputeVersions :: UserId -> NodeId -> GargNoServer Graph
recomputeVersions :: HasNodeStory env err m
=> UserId
-> NodeId
......@@ -324,10 +320,11 @@ recomputeVersions :: HasNodeStory env err m
recomputeVersions uId nId = recomputeGraph uId nId Spinglass BridgenessMethod_Basic Nothing Nothing NgramsTerms NgramsTerms False
------------------------------------------------------------
graphClone :: UserId
graphClone :: HasNodeError err
=> UserId
-> NodeId
-> HyperdataGraphAPI
-> GargNoServer NodeId
-> DBCmd err NodeId
graphClone uId pId (HyperdataGraphAPI { _hyperdataAPIGraph = graph
, _hyperdataAPICamera = camera }) = do
let nodeType = NodeGraph
......
......@@ -34,6 +34,7 @@ import Gargantext.API.Prelude
import Gargantext.Core.Mail.Types (HasMail(..))
import Gargantext.Core.NLP (HasNLPServer(..))
import Gargantext.Database.Query.Table.Node.Error
import Gargantext.Database.Prelude (HasConfig(..), HasConnectionPool(..))
import Gargantext.Prelude.Config
import Gargantext.Prelude.Mail.Types (MailConfig(..), LoginType(NoAuth))
import Gargantext.System.Logging (HasLogger(..), Logger, MonadLogger(..))
......
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