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
157
Issues
157
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
a026a549
Commit
a026a549
authored
Feb 16, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Sugar to connect to database in REPL.
parent
45a0c499
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
10 deletions
+21
-10
Node.hs
src/Gargantext/API/Node.hs
+16
-8
Private.hs
src/Gargantext/Database/Private.hs
+5
-2
No files found.
src/Gargantext/API/Node.hs
View file @
a026a549
...
...
@@ -27,10 +27,11 @@ import System.IO (putStrLn, readFile)
import
Data.Text
(
Text
(),
pack
)
import
Database.PostgreSQL.Simple
(
Connection
)
import
Gargantext.Prelude
import
Gargantext.Types.Main
(
Node
,
NodeId
,
NodeType
)
import
Gargantext.Types.Main
(
Node
,
NodeId
,
NodeType
,
FacetDoc
)
import
Gargantext.Database.Node
(
getNodesWithParentId
,
getNode
,
getNodesWith
,
deleteNode
,
deleteNodes
)
,
deleteNode
,
deleteNodes
,
getDocFacet
)
-- | Node API Types management
...
...
@@ -41,15 +42,18 @@ type NodesAPI = Delete '[JSON] Int
type
NodeAPI
=
Get
'[
J
SON
]
(
Node
Value
)
:<|>
Delete
'[
J
SON
]
Int
-- Example for Document Facet view, to populate the tabular:
-- http://localhost:8008/node/347476/children?type=Document&limit=3
-- /!\ FIXME : nodeType is case sensitive
-- /!\ see NodeTypes in Types/Main.hs
:<|>
"children"
:>
QueryParam
"type"
NodeType
:>
QueryParam
"offset"
Int
:>
QueryParam
"limit"
Int
:>
Get
'[
J
SON
]
[
Node
Value
]
:<|>
"facetDoc"
:>
QueryParam
"type"
NodeType
:>
QueryParam
"offset"
Int
:>
QueryParam
"limit"
Int
:>
Get
'[
J
SON
]
[
FacetDoc
Value
]
-- Depending on the Type of the Node, we could post
-- New documents for a corpus
-- New map list terms
...
...
@@ -66,8 +70,9 @@ roots conn = liftIO (getNodesWithParentId conn 0 Nothing)
nodeAPI
::
Connection
->
NodeId
->
Server
NodeAPI
nodeAPI
conn
id
=
liftIO
(
getNode
conn
id
)
:<|>
deleteNode'
conn
id
:<|>
deleteNode'
conn
id
:<|>
getNodesWith'
conn
id
:<|>
getDocFacet'
conn
id
:<|>
upload
:<|>
query
...
...
@@ -84,6 +89,9 @@ getNodesWith' :: Connection -> NodeId -> Maybe NodeType -> Maybe Int -> Maybe In
->
Handler
[
Node
Value
]
getNodesWith'
conn
id
nodeType
offset
limit
=
liftIO
(
getNodesWith
conn
id
nodeType
offset
limit
)
getDocFacet'
::
Connection
->
NodeId
->
Maybe
NodeType
->
Maybe
Int
->
Maybe
Int
->
Handler
[
FacetDoc
Value
]
getDocFacet'
conn
id
nodeType
offset
limit
=
liftIO
(
getDocFacet
conn
id
nodeType
offset
limit
)
query
::
Text
->
Handler
Text
query
s
=
pure
s
...
...
src/Gargantext/Database/Private.hs
View file @
a026a549
...
...
@@ -13,6 +13,7 @@ import Text.Read (read)
import
Data.Ini
(
readIniFile
,
lookupValue
)
import
Data.Word
(
Word16
)
import
System.IO
(
FilePath
)
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
-- TODO add a reader Monad here
-- read this in the init file
...
...
@@ -34,5 +35,7 @@ databaseParameters fp = do
,
PGS
.
connectPassword
=
val
"DB_PASS"
,
PGS
.
connectDatabase
=
val
"DB_NAME"
}
connectGargandb
::
FilePath
->
IO
Connection
connectGargandb
fp
=
do
parameters
<-
databaseParameters
fp
connect
parameters
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