Commit d49c46a9 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[BASHQL] adding tree command.

parent ac515447
...@@ -62,6 +62,7 @@ module Gargantext.Database ( module Gargantext.Database.Utils ...@@ -62,6 +62,7 @@ module Gargantext.Database ( module Gargantext.Database.Utils
, home, home' , home, home'
, post, post', postR' , post, post', postR'
, del , del' , del , del'
, tree, tree'
) )
where where
...@@ -75,7 +76,7 @@ import Data.Text (Text) ...@@ -75,7 +76,7 @@ import Data.Text (Text)
import Opaleye hiding (FromField) import Opaleye hiding (FromField)
import Data.Aeson import Data.Aeson
import Data.ByteString (ByteString) import Data.ByteString (ByteString)
import Data.List (last) import Data.List (last, concat)
type UserId = Int type UserId = Int
--type NodeId = Int --type NodeId = Int
...@@ -97,8 +98,11 @@ home c = map node_id <$> getNodesWithParentId c 0 Nothing ...@@ -97,8 +98,11 @@ home c = map node_id <$> getNodesWithParentId c 0 Nothing
ls :: Connection -> PWD -> IO [Node Value] ls :: Connection -> PWD -> IO [Node Value]
ls = get ls = get
tree :: Connection -> PWD -> IO [[Node Value]] tree :: Connection -> PWD -> IO [Node Value]
tree c = undefined tree c p = do
ns <- get c p
cs <- mapM (\p' -> get c [p']) $ map node_id ns
pure $ ns <> (concat cs)
-- | TODO -- | TODO
...@@ -145,7 +149,11 @@ ls' = do ...@@ -145,7 +149,11 @@ ls' = do
h <- home c h <- home c
ls c h ls c h
type Children a = Maybe a tree' :: IO [Node Value]
tree' = do
c <- connectGargandb "gargantext.ini"
h <- home c
tree c h
post' :: IO [Int] post' :: IO [Int]
post' = do post' = do
...@@ -159,15 +167,6 @@ post' = do ...@@ -159,15 +167,6 @@ post' = do
) )
postR' :: IO [Int]
postR' = do
c <- connectGargandb "gargantext.ini"
h <- home c
let userId = 1
postR c h [ node userId (last h) Corpus "name" "{}"
, node userId (last h) Project "name" "{}"
]
del' :: [NodeId] -> IO Int del' :: [NodeId] -> IO Int
del' ns = do del' ns = do
......
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