Commit 77c4095c authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FEAT] Cumulative private and social lists (WIP)

parent 4eb0b1c2
......@@ -294,7 +294,7 @@ pairWith cId aId lId = do
type TreeAPI = QueryParams "type" NodeType :> Get '[JSON] (Tree NodeTree)
treeAPI :: NodeId -> GargServer TreeAPI
treeAPI = tree Advanced
treeAPI = tree TreeAdvanced
------------------------------------------------------------------------
-- | TODO Check if the name is less than 255 char
......
{-|
Module : Gargantext.Core.Text.List.Social
Description :
Copyright : (c) CNRS, 2018-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
module Gargantext.Core.Text.List.Social
where
import Gargantext.Database.Prelude
import Gargantext.Database.Query.Tree
import Gargantext.Database.Query.Tree.Root (getRootId)
import Gargantext.Core.Types.Individu
import Gargantext.Database.Admin.Types.Node
import Gargantext.Prelude
import Gargantext.Database.Query.Table.Node.Error
import Gargantext.Database.Admin.Config
findListsId :: (HasNodeError err, HasTreeError err) => NodeMode -> User -> Cmd err [NodeId]
findListsId mode u = do
r <- getRootId u
map _dt_nodeId <$> filter (\n -> _dt_typeId n == nodeTypeId NodeList)
<$> findNodes' mode r
findNodes' :: HasTreeError err
=> NodeMode -> RootId
-> Cmd err [DbTreeNode]
findNodes' Private r = findNodes Private r [NodeFolderPrivate, NodeCorpus, NodeList]
findNodes' Shared r = findNodes Shared r [NodeFolderShared, NodeCorpus, NodeList]
findNodes' Public r = findNodes Public r [NodeFolderPublic, NodeCorpus, NodeList]
......@@ -42,9 +42,10 @@ getUserId UserPublic = nodeError NoUserFound
-- | Username = Text
-- UserName is User
-- that is confusing, we should change this
type Username = Text
getUsername :: HasNodeError err
=> User
-> Cmd err Text
-> Cmd err Username
getUsername (UserName u) = pure u
getUsername (UserDBId i) = do
users <- getUsersWithId i
......
......@@ -29,6 +29,8 @@ module Gargantext.Database.Query.Tree
, dt_nodeId
, dt_typeId
, findShared
, findNodes
, NodeMode(..)
)
where
......@@ -62,7 +64,7 @@ instance Eq DbTreeNode where
------------------------------------------------------------------------
data TreeMode = Basic | Advanced
data TreeMode = TreeBasic | TreeAdvanced
-- | Returns the Tree of Nodes in Database
tree :: HasTreeError err
......@@ -70,8 +72,8 @@ tree :: HasTreeError err
-> RootId
-> [NodeType]
-> Cmd err (Tree NodeTree)
tree Basic = tree_basic
tree Advanced = tree_advanced
tree TreeBasic = tree_basic
tree TreeAdvanced = tree_advanced
-- | Tree basic returns the Tree of Nodes in Database
-- (without shared folders)
......@@ -91,11 +93,23 @@ tree_advanced :: HasTreeError err
-> [NodeType]
-> Cmd err (Tree NodeTree)
tree_advanced r nodeTypes = do
mainRoot <- dbTree r nodeTypes
sharedRoots <- findShared r NodeFolderShared nodeTypes sharedTreeUpdate
publicRoots <- findShared r NodeFolderPublic nodeTypes publicTreeUpdate
mainRoot <- findNodes Private r nodeTypes
sharedRoots <- findNodes Shared r nodeTypes
publicRoots <- findNodes Public r nodeTypes
toTree $ toTreeParent (mainRoot <> sharedRoots <> publicRoots)
------------------------------------------------------------------------
data NodeMode = Private | Shared | Public
findNodes :: HasTreeError err
=> NodeMode
-> RootId -> [NodeType]
-> Cmd err [DbTreeNode]
findNodes Private r nt = dbTree r nt
findNodes Shared r nt = findShared r NodeFolderShared nt sharedTreeUpdate
findNodes Public r nt = findShared r NodeFolderPublic nt publicTreeUpdate
------------------------------------------------------------------------
-- | Collaborative Nodes in the Tree
findShared :: HasTreeError err
......
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