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
8908fae8
Commit
8908fae8
authored
Dec 13, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[document] export stub (JSON)
parent
ed90539a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
102 additions
and
38 deletions
+102
-38
Export.hs
src/Gargantext/API/Node/Corpus/Export.hs
+6
-5
Types.hs
src/Gargantext/API/Node/Corpus/Export/Types.hs
+2
-29
Export.hs
src/Gargantext/API/Node/Document/Export.hs
+25
-0
Types.hs
src/Gargantext/API/Node/Document/Export/Types.hs
+58
-0
Routes.hs
src/Gargantext/API/Routes.hs
+11
-4
No files found.
src/Gargantext/API/Node/Corpus/Export.hs
View file @
8908fae8
{-|
Module : Gargantext.API.Node.Corpus.Export
Description :
Get Metrics from Storage (Database like)
Description :
Corpus export
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
...
...
@@ -25,6 +25,7 @@ import qualified Data.Set as Set
import
qualified
Data.HashMap.Strict
as
HashMap
import
Gargantext.API.Node.Corpus.Export.Types
import
qualified
Gargantext.API.Node.Document.Export.Types
as
DocumentExport
import
Gargantext.API.Ngrams.Types
import
Gargantext.API.Ngrams.Tools
(
filterListWithRoot
,
mapTermListRoot
,
getRepo'
)
import
Gargantext.API.Prelude
(
GargNoServer
)
...
...
@@ -68,16 +69,16 @@ getCorpus cId lId nt' = do
ngs
<-
getNodeNgrams
cId
listId
nt
repo
let
-- uniqId is hash computed already for each document imported in database
r
=
Map
.
intersectionWith
(
\
a
b
->
Document
{
_d_document
=
a
,
_d_ngrams
=
Ngrams
(
Set
.
toList
b
)
(
hash
b
)
,
_d_hash
=
d_hash
a
b
}
(
\
a
b
->
Document
Export
.
Document
{
_d_document
=
a
,
_d_ngrams
=
DocumentExport
.
Ngrams
(
Set
.
toList
b
)
(
hash
b
)
,
_d_hash
=
d_hash
a
b
}
)
ns
(
Map
.
map
(
Set
.
map
unNgramsTerm
)
ngs
)
where
d_hash
a
b
=
hash
[
fromMaybe
""
(
_hd_uniqId
$
_node_hyperdata
a
)
,
hash
b
]
pure
$
Corpus
{
_c_corpus
=
Map
.
elems
r
,
_c_hash
=
hash
$
List
.
map
_d_hash
$
Map
.
elems
r
}
,
_c_hash
=
hash
$
List
.
map
DocumentExport
.
_d_hash
$
Map
.
elems
r
}
getNodeNgrams
::
HasNodeError
err
=>
CorpusId
...
...
src/Gargantext/API/Node/Corpus/Export/Types.hs
View file @
8908fae8
...
...
@@ -17,51 +17,26 @@ import Data.Aeson.TH (deriveJSON)
import
Data.Swagger
import
Data.Text
(
Text
)
import
GHC.Generics
(
Generic
)
import
qualified
Gargantext.API.Node.Document.Export.Types
as
DocumentExport
import
Gargantext.Core.Types
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataDocument
(
..
))
import
Gargantext.Database.Schema.Ngrams
(
NgramsType
(
..
))
import
Servant
-- Corpus Export
data
Corpus
=
Corpus
{
_c_corpus
::
[
Document
]
Corpus
{
_c_corpus
::
[
Document
Export
.
Document
]
,
_c_hash
::
Hash
}
deriving
(
Generic
)
-- | Document Export
data
Document
=
Document
{
_d_document
::
Node
HyperdataDocument
,
_d_ngrams
::
Ngrams
,
_d_hash
::
Hash
}
deriving
(
Generic
)
data
Ngrams
=
Ngrams
{
_ng_ngrams
::
[
Text
]
,
_ng_hash
::
Hash
}
deriving
(
Generic
)
type
Hash
=
Text
-------
instance
ToSchema
Corpus
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_c_"
)
instance
ToSchema
Document
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_d_"
)
instance
ToSchema
Ngrams
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_ng_"
)
-------
instance
ToParamSchema
Corpus
where
toParamSchema
_
=
toParamSchema
(
Proxy
::
Proxy
TODO
)
instance
ToParamSchema
Document
where
toParamSchema
_
=
toParamSchema
(
Proxy
::
Proxy
TODO
)
instance
ToParamSchema
Ngrams
where
toParamSchema
_
=
toParamSchema
(
Proxy
::
Proxy
TODO
)
--------------------------------------------------
type
API
=
Summary
"Corpus Export"
:>
"export"
...
...
@@ -70,5 +45,3 @@ type API = Summary "Corpus Export"
:>
Get
'[
J
SON
]
Corpus
$
(
deriveJSON
(
unPrefix
"_c_"
)
''
C
orpus
)
$
(
deriveJSON
(
unPrefix
"_d_"
)
''
D
ocument
)
$
(
deriveJSON
(
unPrefix
"_ng_"
)
''
N
grams
)
\ No newline at end of file
src/Gargantext/API/Node/Document/Export.hs
0 → 100644
View file @
8908fae8
{-|
Module : Gargantext.API.Node.Document.Export
Description : Document export
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
module
Gargantext.API.Node.Document.Export
where
import
Gargantext.API.Node.Document.Export.Types
import
Gargantext.API.Prelude
(
GargNoServer
)
import
Gargantext.Core.Types
import
Gargantext.Prelude
--------------------------------------------------
-- | Hashes are ordered by Set
getDocuments
::
DocId
->
GargNoServer
[
Document
]
getDocuments
dId
=
do
printDebug
"[getDocuments] dId"
dId
pure
[]
src/Gargantext/API/Node/Document/Export/Types.hs
0 → 100644
View file @
8908fae8
{-|
Module : Gargantext.API.Node.Document.Export.Types
Description : Types for Gargantext.API.Node.Document.Export
Copyright : (c) CNRS, 2017-Present
License : AGPL + CECILL v3
Maintainer : team@gargantext.org
Stability : experimental
Portability : POSIX
-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
module
Gargantext.API.Node.Document.Export.Types
where
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Swagger
import
Data.Text
(
Text
)
import
GHC.Generics
(
Generic
)
import
Gargantext.Core.Types
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataDocument
(
..
))
import
Servant
-- | Document Export
data
Document
=
Document
{
_d_document
::
Node
HyperdataDocument
,
_d_ngrams
::
Ngrams
,
_d_hash
::
Hash
}
deriving
(
Generic
)
data
Ngrams
=
Ngrams
{
_ng_ngrams
::
[
Text
]
,
_ng_hash
::
Hash
}
deriving
(
Generic
)
type
Hash
=
Text
-------
instance
ToSchema
Document
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_d_"
)
instance
ToSchema
Ngrams
where
declareNamedSchema
=
genericDeclareNamedSchema
(
unPrefixSwagger
"_ng_"
)
-------
instance
ToParamSchema
Document
where
toParamSchema
_
=
toParamSchema
(
Proxy
::
Proxy
TODO
)
instance
ToParamSchema
Ngrams
where
toParamSchema
_
=
toParamSchema
(
Proxy
::
Proxy
TODO
)
--------------------------------------------------
type
API
=
Summary
"Document Export"
:>
"export"
:>
Get
'[
J
SON
]
[
Document
]
$
(
deriveJSON
(
unPrefix
"_d_"
)
''
D
ocument
)
$
(
deriveJSON
(
unPrefix
"_ng_"
)
''
N
grams
)
src/Gargantext/API/Routes.hs
View file @
8908fae8
...
...
@@ -36,9 +36,11 @@ import Servant.Swagger.UI
import
qualified
Gargantext.API.Ngrams.List
as
List
import
qualified
Gargantext.API.Node.Contact
as
Contact
import
qualified
Gargantext.API.Node.Corpus.Annuaire
as
Annuaire
import
qualified
Gargantext.API.Node.Corpus.Export
as
Export
import
qualified
Gargantext.API.Node.Corpus.Export.Types
as
Export
import
qualified
Gargantext.API.Node.Corpus.Export
as
Corpus
Export
import
qualified
Gargantext.API.Node.Corpus.Export.Types
as
Corpus
Export
import
qualified
Gargantext.API.Node.Corpus.New
as
New
import
qualified
Gargantext.API.Node.Document.Export
as
DocumentExport
import
qualified
Gargantext.API.Node.Document.Export.Types
as
DocumentExport
import
qualified
Gargantext.API.Public
as
Public
import
Gargantext.API.Admin.Auth.Types
(
AuthRequest
,
AuthResponse
,
AuthenticatedUser
(
..
),
PathId
(
..
))
import
Gargantext.API.Admin.Auth
(
withAccess
)
...
...
@@ -111,7 +113,7 @@ type GargPrivateAPI' =
:>
NodeNodeAPI
HyperdataAny
:<|>
"corpus"
:>
Capture
"node_id"
CorpusId
:>
Export
.
API
:>
Corpus
Export
.
API
-- Annuaire endpoint
{-
...
...
@@ -133,6 +135,9 @@ type GargPrivateAPI' =
:>
"ngrams"
:>
TableNgramsApi
:<|>
"texts"
:>
Capture
"node_id"
DocId
:>
DocumentExport
.
API
-- :<|> "counts" :> Stream GET NewLineFraming '[JSON] Count :> CountAPI
-- TODO-SECURITY
:<|>
"count"
:>
Summary
"Count endpoint"
...
...
@@ -217,7 +222,7 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAny
)
uid
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataCorpus
)
uid
:<|>
nodeNodeAPI
(
Proxy
::
Proxy
HyperdataAny
)
uid
:<|>
Export
.
getCorpus
-- uid
:<|>
Corpus
Export
.
getCorpus
-- uid
-- :<|> nodeAPI (Proxy :: Proxy HyperdataContact) uid
:<|>
nodeAPI
(
Proxy
::
Proxy
HyperdataAnnuaire
)
uid
:<|>
Contact
.
api
uid
...
...
@@ -225,6 +230,8 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
:<|>
withAccess
(
Proxy
::
Proxy
TableNgramsApi
)
Proxy
uid
<$>
PathNode
<*>
apiNgramsTableDoc
:<|>
DocumentExport
.
getDocuments
:<|>
count
-- TODO: undefined
-- :<|> withAccess (Proxy :: Proxy (Search.API Search.SearchResult)) Proxy uid
...
...
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