Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
H
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
Przemyslaw Kaminski
haskell-gargantext
Commits
73114c78
Commit
73114c78
authored
Apr 08, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FACTO] VIZ.APIS
parent
80e7ae38
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
153 additions
and
76 deletions
+153
-76
API.hs
src/Gargantext/API.hs
+4
-10
Node.hs
src/Gargantext/API/Node.hs
+22
-61
Types.hs
src/Gargantext/API/Types.hs
+41
-0
CSV.hs
src/Gargantext/Text/Parsers/CSV.hs
+6
-3
API.hs
src/Gargantext/Viz/Graph/API.hs
+78
-0
API.hs
src/Gargantext/Viz/Phylo/API.hs
+2
-2
No files found.
src/Gargantext/API.hs
View file @
73114c78
...
...
@@ -79,24 +79,18 @@ import Gargantext.API.FrontEnd (FrontEndAPI, frontEndServer)
import
Gargantext.API.Auth
(
AuthRequest
,
AuthResponse
,
auth
)
import
Gargantext.API.Ngrams
(
HasRepo
(
..
),
HasRepoSaver
(
..
),
saveRepo
)
import
Gargantext.API.Node
(
GargServer
,
Roots
,
roots
,
NodeAPI
,
nodeAPI
,
NodesAPI
,
nodesAPI
,
GraphAPI
,
graphAPI
,
TreeAPI
,
treeAPI
,
HyperdataAny
,
HyperdataCorpus
,
HyperdataAnnuaire
)
import
Gargantext.API.Types
import
Gargantext.API.Node
import
Gargantext.Database.Schema.Node
(
HasNodeError
(
..
),
NodeError
)
--import Gargantext.Database.Node.Contact (HyperdataContact)
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Utils
(
HasConnection
)
import
Gargantext.Database.Tree
(
HasTreeError
(
..
),
TreeError
)
import
Gargantext.Database.Types.Node
(
NodeId
,
CorpusId
,
AnnuaireId
)
import
Gargantext.API.Count
(
CountAPI
,
count
,
Query
)
import
Gargantext.API.Search
(
SearchAPI
,
search
,
SearchQuery
)
import
Gargantext.Database.Facet
import
Gargantext.Viz.Graph.API
--import Gargantext.API.Orchestrator
--import Gargantext.API.Orchestrator.Types
...
...
src/Gargantext/API/Node.hs
View file @
73114c78
...
...
@@ -7,7 +7,19 @@ Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-- TODO-ACCESS: CanGetNode
-- TODO-EVENTS: No events as this is a read only query.
Node API
-------------------------------------------------------------------
-- TODO-ACCESS: access by admin only.
-- At first let's just have an isAdmin check.
-- Later: check userId CanDeleteNodes Nothing
-- TODO-EVENTS: DeletedNodes [NodeId]
-- {"tag": "DeletedNodes", "nodes": [Int*]}
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
...
...
@@ -22,17 +34,9 @@ Node API
{-# LANGUAGE TypeOperators #-}
module
Gargantext.API.Node
(
module
Gargantext
.
API
.
Node
,
HyperdataAny
(
..
)
,
HyperdataAnnuaire
(
..
)
,
HyperdataCorpus
(
..
)
,
HyperdataResource
(
..
)
,
HyperdataUser
(
..
)
,
HyperdataDocument
(
..
)
,
HyperdataDocumentV3
(
..
)
)
where
import
Control.Lens
(
prism'
,
set
)
where
import
Control.Lens
(
prism'
)
import
Control.Monad
((
>>
))
import
Control.Monad.IO.Class
(
liftIO
)
import
Data.Aeson
(
FromJSON
,
ToJSON
)
...
...
@@ -41,34 +45,29 @@ import Data.Text (Text())
import
Data.Time
(
UTCTime
)
import
GHC.Generics
(
Generic
)
import
Gargantext.API.Metrics
import
Gargantext.API.Ngrams
(
TabType
(
..
),
TableNgramsApi
,
TableNgramsApiGet
,
tableNgramsPatch
,
getTableNgrams
,
HasRepo
,
QueryParamR
)
import
Gargantext.API.Ngrams.Tools
import
Gargantext.API.Ngrams
(
TabType
(
..
),
TableNgramsApi
,
TableNgramsApiGet
,
tableNgramsPatch
,
getTableNgrams
,
QueryParamR
)
import
Gargantext.API.Search
(
SearchAPI
,
searchIn
,
SearchInQuery
)
import
Gargantext.Core.Types
(
Offset
,
Limit
,
ListType
(
..
),
HasInvalidError
)
import
Gargantext.API.Types
import
Gargantext.Core.Types
(
Offset
,
Limit
)
import
Gargantext.Core.Types.Main
(
Tree
,
NodeTree
)
import
Gargantext.Database.Facet
(
FacetDoc
,
runViewDocuments
,
OrderBy
(
..
),
FacetChart
,
runViewAuthorsDoc
)
import
qualified
Gargantext.Database.Metrics
as
Metrics
import
Gargantext.Database.Metrics.NgramsByNode
(
getNodesByNgramsOnlyUser
)
import
Gargantext.Database.Node.Children
(
getChildren
)
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
(
..
))
import
Gargantext.Database.Schema.Node
(
getNodesWithParentId
,
getNode
,
deleteNode
,
deleteNodes
,
mkNodeWithParent
,
JSONB
,
NodeError
(
..
),
HasNodeError
(
..
))
import
Gargantext.Database.Schema.Node
(
defaultList
)
import
Gargantext.Database.Schema.NodeNode
(
nodesToFavorite
,
nodesToTrash
)
import
Gargantext.Database.Tree
(
treeDB
,
HasTreeError
(
..
),
TreeError
(
..
))
import
Gargantext.Database.Types.Node
import
Gargantext.Database.Types.Node
(
CorpusId
,
ContactId
)
import
Gargantext.Database.Utils
-- (Cmd, CmdM)
import
Gargantext.Prelude
import
Gargantext.API.Settings
import
Gargantext.Text.Metrics
(
Scored
(
..
))
import
Gargantext.Viz.Graph
hiding
(
Node
)
-- (Graph(_graph_metadata),LegendField(..), GraphMetadata(..),readGraphFromJson,defaultGraph)
import
Gargantext.Viz.Graph.Tools
(
cooc2graph
)
import
Gargantext.Viz.Phylo.API
(
getPhylo
)
import
Gargantext.Viz.Phylo
hiding
(
Tree
)
import
Gargantext.Viz.Phylo.API
(
getPhylo
)
import
Servant
import
Test.QuickCheck
(
elements
)
import
Test.QuickCheck.Arbitrary
(
Arbitrary
,
arbitrary
)
import
qualified
Data.Map
as
Map
import
qualified
Gargantext.Database.Metrics
as
Metrics
import
qualified
Gargantext.Database.Node.Update
as
U
(
update
,
Update
(
..
))
{-
...
...
@@ -76,23 +75,7 @@ import qualified Gargantext.Text.List.Learn as Learn
import qualified Data.Vector as Vec
--}
type
GargServer
api
=
forall
env
err
m
.
(
CmdM
env
err
m
,
HasNodeError
err
,
HasInvalidError
err
,
HasTreeError
err
,
HasRepo
env
,
HasSettings
env
)
=>
ServerT
api
m
-------------------------------------------------------------------
-- TODO-ACCESS: access by admin only.
-- At first let's just have an isAdmin check.
-- Later: check userId CanDeleteNodes Nothing
-- TODO-EVENTS: DeletedNodes [NodeId]
-- {"tag": "DeletedNodes", "nodes": [Int*]}
type
NodesAPI
=
Delete
'[
J
SON
]
Int
-- | Delete Nodes
...
...
@@ -291,35 +274,13 @@ type ChartApi = Summary " Chart API"
-- :<|> "query" :> Capture "string" Text :> Get '[JSON] Text
------------------------------------------------------------------------
-- TODO-ACCESS: CanGetNode
-- TODO-EVENTS: No events as this is a read only query.
type
GraphAPI
=
Get
'[
J
SON
]
Graph
graphAPI
::
NodeId
->
GargServer
GraphAPI
graphAPI
nId
=
do
nodeGraph
<-
getNode
nId
HyperdataGraph
let
metadata
=
GraphMetadata
"Title"
[
maybe
0
identity
$
_node_parentId
nodeGraph
]
[
LegendField
1
"#FFF"
"Cluster"
,
LegendField
2
"#FFF"
"Cluster"
]
-- (map (\n -> LegendField n "#FFFFFF" (pack $ show n)) [1..10])
let
cId
=
maybe
(
panic
"no parentId"
)
identity
$
_node_parentId
nodeGraph
lId
<-
defaultList
cId
ngs
<-
filterListWithRoot
GraphTerm
<$>
mapTermListRoot
[
lId
]
NgramsTerms
myCooc
<-
Map
.
filter
(
>
1
)
<$>
getCoocByNgrams
(
Diagonal
False
)
<$>
groupNodesByNgrams
ngs
<$>
getNodesByNgramsOnlyUser
cId
NgramsTerms
(
Map
.
keys
ngs
)
liftIO
$
set
graph_metadata
(
Just
metadata
)
<$>
cooc2graph
myCooc
type
PhyloAPI
=
Summary
"Phylo API"
-- :> QueryParam "param" PhyloQueryView
:>
Get
'[
J
SON
]
PhyloView
phyloAPI
::
NodeId
->
GargServer
PhyloAPI
phyloAPI
n
=
pure
$
getPhylo
n
...
...
src/Gargantext/API/Types.hs
0 → 100644
View file @
73114c78
{-|
Module : Gargantext.API.Types
Description : Server API main Types
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE RankNTypes #-}
module
Gargantext.API.Types
where
import
Servant
import
Gargantext.API.Settings
import
Gargantext.API.Ngrams
import
Gargantext.Database.Tree
import
Gargantext.Core.Types
import
Gargantext.Database.Utils
import
Gargantext.Database.Schema.Node
type
GargServer
api
=
forall
env
err
m
.
(
CmdM
env
err
m
,
HasNodeError
err
,
HasInvalidError
err
,
HasTreeError
err
,
HasRepo
env
,
HasSettings
env
)
=>
ServerT
api
m
src/Gargantext/Text/Parsers/CSV.hs
View file @
73114c78
...
...
@@ -31,7 +31,6 @@ import Data.Time.Segment (jour)
import
Data.Vector
(
Vector
)
import
qualified
Data.Vector
as
V
import
Safe
(
tailMay
)
import
Gargantext.Database.Types.Node
(
HyperdataDocument
(
..
))
import
Gargantext.Text
...
...
@@ -124,10 +123,14 @@ splitDoc' contextSize (CsvDoc t s py pm pd abst auth) = V.fromList $ [firstDoc]
firstDoc
=
CsvDoc
t
s
py
pm
pd
firstAbstract
auth
firstAbstract
=
head'
"splitDoc'1"
abstracts
nextDocs
=
map
(
\
txt
->
CsvDoc
(
head'
"splitDoc'2"
$
sentences
txt
)
s
py
pm
pd
(
unsentences
$
tail'
$
sentences
txt
)
auth
)
(
tail'
abstracts
)
nextDocs
=
map
(
\
txt
->
CsvDoc
(
head'
"splitDoc'2"
$
sentences
txt
)
s
py
pm
pd
(
unsentences
$
tail'
"splitDoc'1"
$
sentences
txt
)
auth
)
(
tail'
"splitDoc'2"
abstracts
)
abstracts
=
(
splitBy
$
contextSize
)
abst
tail'
x
=
maybe
[
""
]
identity
(
tailMay
x
)
---------------------------------------------------------------
---------------------------------------------------------------
...
...
src/Gargantext/Viz/Graph/API.hs
0 → 100644
View file @
73114c78
{-|
Module : Gargantext.Viz.Phylo.Tools
Description : Phylomemy Tools to build/manage it
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# LANGUAGE RankNTypes #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# LANGUAGE OverloadedStrings #-}
-- allows to write Text literals
{-# LANGUAGE OverloadedLists #-}
-- allows to write Map and HashMap as lists
{-# LANGUAGE DataKinds #-}
module
Gargantext.Viz.Graph.API
where
import
Control.Monad.IO.Class
(
liftIO
)
import
Control.Lens
(
set
)
--import Servant.Job.Utils (swaggerOptions)
import
Gargantext.Database.Schema.Ngrams
import
Gargantext.API.Types
import
Gargantext.Database.Metrics.NgramsByNode
(
getNodesByNgramsOnlyUser
)
import
Gargantext.Database.Schema.Node
(
getNode
)
import
Gargantext.Database.Types.Node
-- (GraphId, ListId, CorpusId, NodeId)
import
Gargantext.Prelude
import
Gargantext.API.Ngrams.Tools
import
Gargantext.Core.Types.Main
import
Gargantext.Viz.Graph.Tools
-- (cooc2graph)
import
Gargantext.Database.Schema.Node
(
defaultList
)
import
Gargantext.Viz.Graph
import
Servant
import
qualified
Data.Map
as
Map
{-
getgraph :: GraphId -> GraphView
getgraph _GraphId = phyloView
--getgraph :: GraphId -> Maybe PhyloQueryView -> PhyloView
--getgraph _GraphId _phyloQueryView = phyloView
postgraph :: CorpusId -> Maybe ListId -> GraphQueryBuild -> Phylo
postgraph = undefined
putgraph :: GraphId -> Maybe ListId -> PhyloQueryBuild -> Phylo
putgraph = undefined
-}
type
GraphAPI
=
Get
'[
J
SON
]
Graph
graphAPI
::
NodeId
->
GargServer
GraphAPI
graphAPI
nId
=
do
nodeGraph
<-
getNode
nId
HyperdataGraph
let
metadata
=
GraphMetadata
"Title"
[
maybe
0
identity
$
_node_parentId
nodeGraph
]
[
LegendField
1
"#FFF"
"Cluster"
,
LegendField
2
"#FFF"
"Cluster"
]
-- (map (\n -> LegendField n "#FFFFFF" (pack $ show n)) [1..10])
let
cId
=
maybe
(
panic
"no parentId"
)
identity
$
_node_parentId
nodeGraph
lId
<-
defaultList
cId
ngs
<-
filterListWithRoot
GraphTerm
<$>
mapTermListRoot
[
lId
]
NgramsTerms
myCooc
<-
Map
.
filter
(
>
1
)
<$>
getCoocByNgrams
(
Diagonal
False
)
<$>
groupNodesByNgrams
ngs
<$>
getNodesByNgramsOnlyUser
cId
NgramsTerms
(
Map
.
keys
ngs
)
liftIO
$
set
graph_metadata
(
Just
metadata
)
<$>
cooc2graph
myCooc
-- | Instances
src/Gargantext/Viz/Phylo/API.hs
View file @
73114c78
{-|
Module : Gargantext.Viz.Phylo.
Tools
Description : Phylo
memy Tools to build/manage it
Module : Gargantext.Viz.Phylo.
API
Description : Phylo
API
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
...
...
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