Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
147
Issues
147
List
Board
Labels
Milestones
Merge Requests
6
Merge Requests
6
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
99e95bb1
Commit
99e95bb1
authored
Sep 12, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[REST] Tree api.
parent
2487bd75
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
56 additions
and
11 deletions
+56
-11
package.yaml
package.yaml
+1
-0
API.hs
src/Gargantext/API.hs
+9
-2
Node.hs
src/Gargantext/API/Node.hs
+5
-0
Main.hs
src/Gargantext/Core/Types/Main.hs
+14
-1
Bashql.hs
src/Gargantext/Database/Bashql.hs
+26
-7
Config.hs
src/Gargantext/Database/Config.hs
+0
-1
stack.yaml
stack.yaml
+1
-0
No files found.
package.yaml
View file @
99e95bb1
...
...
@@ -116,6 +116,7 @@ library:
-
protolude
-
pureMD5
-
SHA
-
rake
-
regex-compat
-
resourcet
-
safe
...
...
src/Gargantext/API.hs
View file @
99e95bb1
...
...
@@ -68,7 +68,8 @@ import Gargantext.API.FrontEnd (FrontEndAPI, frontEndServer)
import
Gargantext.API.Node
(
Roots
,
roots
,
NodeAPI
,
nodeAPI
,
NodesAPI
,
nodesAPI
,
GraphAPI
,
graphAPI
,
GraphAPI
,
graphAPI
,
TreeAPI
,
treeAPI
)
import
Gargantext.API.Count
(
CountAPI
,
count
,
Query
)
import
Gargantext.API.Search
(
SearchAPI
,
search
,
SearchQuery
)
...
...
@@ -219,6 +220,11 @@ type GargAPI =
:<|>
"graph"
:>
Summary
"Graph endpoint"
:>
Capture
"id"
Int
:>
GraphAPI
-- Tree endpoint
:<|>
"tree"
:>
Summary
"Tree endpoint"
:>
Capture
"id"
Int
:>
TreeAPI
-- :<|> "scraper" :> WithCallbacks ScraperAPI
...
...
@@ -245,8 +251,9 @@ server env = do
:<|>
nodeAPI
conn
:<|>
nodesAPI
conn
:<|>
count
:<|>
search
conn
:<|>
search
conn
:<|>
graphAPI
conn
:<|>
treeAPI
conn
-- :<|> orchestrator
where
conn
=
env
^.
env_conn
...
...
src/Gargantext/API/Node.hs
View file @
99e95bb1
...
...
@@ -49,6 +49,7 @@ import Gargantext.Database.Facet (FacetDoc, getDocFacet
import
Gargantext.TextFlow
import
Gargantext.Viz.Graph
(
Graph
)
import
Gargantext.Core
(
Lang
(
..
))
import
Gargantext.Core.Types.Main
(
Tree
)
import
Gargantext.Text.Terms
(
TermType
(
..
))
-------------------------------------------------------------------
-------------------------------------------------------------------
...
...
@@ -111,6 +112,10 @@ type GraphAPI = Get '[JSON] Graph
graphAPI
::
Connection
->
NodeId
->
Server
GraphAPI
graphAPI
_
_
=
liftIO
$
textFlow
(
Mono
EN
)
(
Contexts
contextText
)
type
TreeAPI
=
Get
'[
J
SON
]
(
Tree
NodeType
)
treeAPI
::
Connection
->
NodeId
->
Server
TreeAPI
treeAPI
_
_
=
undefined
nodeAPI
::
Connection
->
NodeId
->
Server
NodeAPI
nodeAPI
conn
id
=
liftIO
(
putStrLn
(
"/node"
::
Text
)
>>
getNode
conn
id
)
...
...
src/Gargantext/Core/Types/Main.hs
View file @
99e95bb1
...
...
@@ -20,17 +20,30 @@ Portability : POSIX
module
Gargantext.Core.Types.Main
where
------------------------------------------------------------------------
import
Data.Aeson
(
FromJSON
,
ToJSON
)
import
Data.Eq
(
Eq
())
import
Data.Monoid
((
<>
))
import
Data.Text
(
Text
)
import
Data.Swagger
import
Gargantext.Database.Types.Node
import
Gargantext.Prelude
import
GHC.Generics
(
Generic
)
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
------------------------------------------------------------------------
-- All the Database is structred like a hierarchical Tree
data
Tree
a
=
NodeT
a
[
Tree
a
]
deriving
(
Show
,
Read
,
Eq
)
deriving
(
Show
,
Read
,
Eq
,
Generic
)
instance
ToJSON
(
Tree
NodeType
)
instance
FromJSON
(
Tree
NodeType
)
instance
ToSchema
(
Tree
NodeType
)
instance
Arbitrary
(
Tree
NodeType
)
where
arbitrary
=
elements
[
userTree
,
userTree
]
-- data Tree a = NodeT a [Tree a]
-- same as Data.Tree
...
...
src/Gargantext/Database/Bashql.hs
View file @
99e95bb1
...
...
@@ -58,8 +58,9 @@ AMS, and by SIAM.
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE FlexibleContexts #-}
module
Gargantext.Database.Bashql
(
get
module
Gargantext.Database.Bashql
(
get
,
get'
,
ls
,
ls'
,
home
,
home'
,
post
,
post'
...
...
@@ -69,16 +70,19 @@ module Gargantext.Database.Bashql ( get
)
where
import
Gargantext.Core.Types
import
Gargantext.Database.Utils
(
connectGargandb
)
import
Gargantext.Database.Node
import
Gargantext.Prelude
import
Control.Monad.Reader
-- (Reader, ask)
import
Database.PostgreSQL.Simple
(
Connection
)
import
Data.Text
(
Text
,
pack
)
import
Opaleye
hiding
(
FromField
)
import
Data.Aeson
import
Data.List
(
last
,
concat
)
import
Gargantext.Core.Types
import
Gargantext.Database.Utils
(
connectGargandb
)
import
Gargantext.Database.Node
import
Gargantext.Prelude
import
Opaleye
hiding
(
FromField
)
--type UserId = Int
--type NodeId = Int
...
...
@@ -100,9 +104,10 @@ home c = map node_id <$> getNodesWithParentId c 0 Nothing
ls
::
Connection
->
PWD
->
IO
[
Node
Value
]
ls
=
get
tree
::
Connection
->
PWD
->
IO
[
Node
Value
]
tree
c
p
=
do
ns
<-
get
c
p
ns
<-
get
c
p
children
<-
mapM
(
\
p'
->
get
c
[
p'
])
$
map
node_id
ns
pure
$
ns
<>
(
concat
children
)
...
...
@@ -140,11 +145,24 @@ del c ns = deleteNodes c ns
-- Tests
--------------------------------------------------------------
get'
::
PWD
->
Reader
Connection
(
IO
[
Node
Value
])
get'
[]
=
pure
$
pure
[]
get'
pwd
=
do
connection
<-
ask
pure
$
runQuery
connection
$
selectNodesWithParentID
(
last
pwd
)
home'
::
IO
PWD
home'
=
do
c
<-
connectGargandb
"gargantext.ini"
home
c
--home'' :: Reader Connection (IO PWD)
--home'' = do
-- c <- ask
-- liftIO $ home c
ls'
::
IO
[
Node
Value
]
ls'
=
do
c
<-
connectGargandb
"gargantext.ini"
...
...
@@ -203,3 +221,4 @@ del' ns = do
del
c
ns
-- corporaOf :: Username -> IO [Corpus]
src/Gargantext/Database/Config.hs
View file @
99e95bb1
...
...
@@ -66,4 +66,3 @@ nodeTypeId tn = fromMaybe (panic $ pack $ "Typename " <> show tn <> " does not e
stack.yaml
View file @
99e95bb1
...
...
@@ -27,6 +27,7 @@ extra-deps:
-
kmeans-vector-0.3.2
-
probable-0.1.3
-
protolude-0.2
-
rake-0.0.1
-
servant-0.13
-
servant-auth-0.3.0.1
-
servant-client-0.13
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment