diff --git a/package.yaml b/package.yaml index 815c8af47edd5ee52c39ab3af52fa8443f7db714..c05ba4debea0904d879c8031173e375648da8d46 100644 --- a/package.yaml +++ b/package.yaml @@ -1,5 +1,5 @@ name: gargantext -version: '0.0.3.4' +version: '0.0.3.7' synopsis: Search, map, share description: Please see README.md category: Data diff --git a/src/Gargantext/Core/Viz/Graph/API.hs b/src/Gargantext/Core/Viz/Graph/API.hs index 21fac7dee62a8e6b92b05c04222cdda8707b907e..8d332a52c90ef32c96a18f53daa8be150834b0a3 100644 --- a/src/Gargantext/Core/Viz/Graph/API.hs +++ b/src/Gargantext/Core/Viz/Graph/API.hs @@ -239,11 +239,11 @@ type GraphVersionsAPI = Summary "Graph versions" graphVersionsAPI :: UserId -> NodeId -> GargServer GraphVersionsAPI graphVersionsAPI u n = - graphVersions n + graphVersions 0 n :<|> recomputeVersions u n -graphVersions :: NodeId -> GargNoServer GraphVersions -graphVersions nId = do +graphVersions :: Int -> NodeId -> GargNoServer GraphVersions +graphVersions n nId = do nodeGraph <- getNodeWith nId (Proxy :: Proxy HyperdataGraph) let graph = nodeGraph @@ -261,12 +261,19 @@ graphVersions nId = do identity $ nodeGraph ^. node_parent_id - listId <- defaultList cId - repo <- getRepo' [listId] - let v = repo ^. unNodeStory . at listId . _Just . a_version + 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 - pure $ GraphVersions { gv_graph = listVersion - , gv_repo = v } + pure $ GraphVersions { gv_graph = listVersion + , gv_repo = v } recomputeVersions :: UserId -> NodeId -> GargNoServer Graph recomputeVersions uId nId = recomputeGraph uId nId Nothing diff --git a/src/Gargantext/Database/Query/Table/Node.hs b/src/Gargantext/Database/Query/Table/Node.hs index 4b8aec29e9b5ad1d98fab756a876c2adc3c9dd2b..f3544efe717ab62d4a25f118ceb6128dc7e28b90 100644 --- a/src/Gargantext/Database/Query/Table/Node.hs +++ b/src/Gargantext/Database/Query/Table/Node.hs @@ -336,6 +336,9 @@ defaultList :: (HasNodeError err, HasDBid NodeType) => CorpusId -> Cmd err ListI defaultList cId = maybe (nodeError NoListFound) (pure . view node_id) . headMay =<< getListsWithParentId cId +defaultListMaybe :: (HasNodeError err, HasDBid NodeType) => CorpusId -> Cmd err (Maybe NodeId) +defaultListMaybe cId = headMay <$> map (view node_id ) <$> getListsWithParentId cId + getListsWithParentId :: HasDBid NodeType => NodeId -> Cmd err [Node HyperdataList] getListsWithParentId n = runOpaQuery $ selectNodesWith' n (Just NodeList)