Commit e9db08a1 authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[graph update] add "force" parameter to force graph recomputation

Otherwise the "refresh" buttons won't work because list version
doesn't change.
parent 33bf8ea5
Pipeline #2332 passed with stage
in 26 minutes and 16 seconds
......@@ -36,7 +36,7 @@ import Gargantext.Database.Admin.Types.Node
import Gargantext.Database.Query.Table.Node (getNode)
import Gargantext.Database.Schema.Node (node_parent_id)
import Gargantext.Database.Schema.Ngrams (NgramsType(NgramsTerms))
import Gargantext.Prelude (Ord, Eq, (<$>), ($), liftBase, (.), printDebug, pure, show, cs, (<>), panic)
import Gargantext.Prelude (Bool(..), Ord, Eq, (<$>), ($), liftBase, (.), printDebug, pure, show, cs, (<>), panic)
import qualified Gargantext.Utils.Aeson as GUA
import Prelude (Enum, Bounded, minBound, maxBound)
import Servant
......@@ -95,7 +95,7 @@ updateNode uId nId (UpdateNodeParamsGraph metric) logStatus = do
, _scst_events = Just []
}
_ <- recomputeGraph uId nId (Just metric)
_ <- recomputeGraph uId nId (Just metric) True
pure JobLog { _scst_succeeded = Just 2
, _scst_failed = Just 0
......
......@@ -120,8 +120,9 @@ recomputeGraph :: FlowCmdM env err m
=> UserId
-> NodeId
-> Maybe GraphMetric
-> Bool
-> m Graph
recomputeGraph _uId nId maybeDistance = do
recomputeGraph _uId nId maybeDistance force = do
nodeGraph <- getNodeWith nId (Proxy :: Proxy HyperdataGraph)
let
graph = nodeGraph ^. node_hyperdata . hyperdataGraph
......@@ -142,21 +143,22 @@ recomputeGraph _uId nId maybeDistance = do
repo <- getRepo' [listId]
let v = repo ^. unNodeStory . at listId . _Just . a_version
let computeG mt = do
g <- computeGraph cId similarity NgramsTerms repo
let g' = set graph_metadata mt g
_ <- updateHyperdata nId (HyperdataGraph (Just g') camera)
pure g'
case graph of
Nothing -> do
graph' <- computeGraph cId similarity NgramsTerms repo
mt <- defaultGraphMetadata cId "Title" repo (fromMaybe Order1 maybeDistance)
let graph'' = set graph_metadata (Just mt) graph'
_ <- updateHyperdata nId (HyperdataGraph (Just graph'') camera)
pure $ trace "[G.V.G.API.recomputeGraph] Graph empty, computed" graph''
Just graph' -> if listVersion == Just v
g <- computeG $ Just mt
pure $ trace "[G.V.G.API.recomputeGraph] Graph empty, computed" g
Just graph' -> if (listVersion == Just v) && (not force)
then pure graph'
else do
graph'' <- computeGraph cId similarity NgramsTerms repo
let graph''' = set graph_metadata graphMetadata graph''
_ <- updateHyperdata nId (HyperdataGraph (Just graph''') camera)
pure $ trace "[G.V.G.API] Graph exists, recomputing" graph'''
g <- computeG graphMetadata
pure $ trace "[G.V.G.API] Graph exists, recomputing" g
computeGraph :: FlowCmdM env err m
......@@ -242,7 +244,7 @@ graphRecompute u n logStatus = do
, _scst_remaining = Just 1
, _scst_events = Just []
}
_g <- trace (show u) $ recomputeGraph u n Nothing
_g <- trace (show u) $ recomputeGraph u n Nothing False
pure JobLog { _scst_succeeded = Just 1
, _scst_failed = Just 0
, _scst_remaining = Just 0
......@@ -297,7 +299,7 @@ recomputeVersions :: FlowCmdM env err m
=> UserId
-> NodeId
-> m Graph
recomputeVersions uId nId = recomputeGraph uId nId Nothing
recomputeVersions uId nId = recomputeGraph uId nId Nothing False
------------------------------------------------------------
graphClone :: UserId
......
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