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
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
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
4baef92d
Commit
4baef92d
authored
Jan 10, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[docs download] fix CSV return value
parent
07e34aa5
Pipeline
#2330
passed with stage
in 26 minutes and 12 seconds
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
10 deletions
+27
-10
Client.hs
src/Gargantext/API/Client.hs
+2
-1
Export.hs
src/Gargantext/API/Node/Document/Export.hs
+5
-2
Types.hs
src/Gargantext/API/Node/Document/Export/Types.hs
+18
-5
LegacyAPI.hs
src/Gargantext/Core/Viz/Phylo/Legacy/LegacyAPI.hs
+2
-2
No files found.
src/Gargantext/API/Client.hs
View file @
4baef92d
...
...
@@ -360,7 +360,8 @@ waitDocumentNgramsTableAsyncJob :: Token -> DocId -> JobID 'Unsafe -> ClientM (J
-- document export API
getDocumentExportJSON
::
Token
->
DocId
->
ClientM
DocumentExport
.
DocumentExport
getDocumentExportCSV
::
Token
->
DocId
->
ClientM
[
DocumentExport
.
Document
]
getDocumentExportCSV
::
Token
->
DocId
->
ClientM
Text
--getDocumentExportCSV :: Token -> DocId -> ClientM [DocumentExport.Document]
-- count api
postCountQuery
::
Token
->
Query
->
ClientM
Counts
...
...
src/Gargantext/API/Node/Document/Export.hs
View file @
4baef92d
...
...
@@ -11,6 +11,8 @@ Portability : POSIX
module
Gargantext.API.Node.Document.Export
where
import
qualified
Data.ByteString.Lazy.Char8
as
BSC
import
Data.Csv
(
encodeDefaultOrderedByName
)
import
qualified
Data.Text
as
T
import
Data.Version
(
showVersion
)
import
Gargantext.API.Node.Document.Export.Types
...
...
@@ -66,9 +68,10 @@ getDocumentsJSON uId pId = do
getDocumentsCSV
::
UserId
->
DocId
->
GargNoServer
[
Document
]
->
GargNoServer
T
.
Text
--
[Document]
getDocumentsCSV
uId
pId
=
do
DocumentExport
{
_de_documents
}
<-
getDocumentsJSON
uId
pId
pure
$
_de_documents
pure
$
T
.
pack
$
BSC
.
unpack
$
encodeDefaultOrderedByName
_de_documents
src/Gargantext/API/Node/Document/Export/Types.hs
View file @
4baef92d
...
...
@@ -16,11 +16,13 @@ module Gargantext.API.Node.Document.Export.Types where
import
Data.Aeson.TH
(
deriveJSON
)
import
Data.Csv
(
DefaultOrdered
(
..
),
ToNamedRecord
(
..
),
(
.=
),
header
,
namedRecord
)
import
Data.Swagger
--import qualified Data.Text as T
import
qualified
Data.Text.Encoding
as
TE
import
Gargantext.Core.Types
import
Gargantext.Core.Utils.Prefix
(
unPrefix
,
unPrefixSwagger
)
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataDocument
(
..
))
import
Gargantext.Database.Schema.Node
(
NodePoly
(
..
))
import
Gargantext.Utils.Servant
(
CSV
)
--
import Gargantext.Utils.Servant (CSV)
import
Protolude
--import Protolude.Partial (read)
import
Servant
...
...
@@ -41,12 +43,23 @@ data Document =
--instance Read Document where
-- read "" = panic "not implemented"
instance
DefaultOrdered
Document
where
headerOrder
_
=
header
[
"id"
,
"name"
]
headerOrder
_
=
header
[
"Publication Day"
,
"Publication Month"
,
"Publication Year"
,
"Authors"
,
"Title"
,
"Source"
,
"Abstract"
]
instance
ToNamedRecord
Document
where
toNamedRecord
(
Document
{
_d_document
=
Node
{
..
}})
=
namedRecord
[
"id"
.=
_node_id
,
"name"
.=
_node_name
]
[
"Publication Day"
.=
_hd_publication_day
_node_hyperdata
,
"Publication Month"
.=
_hd_publication_month
_node_hyperdata
,
"Publication Year"
.=
_hd_publication_year
_node_hyperdata
,
"Authors"
.=
_hd_authors
_node_hyperdata
,
"Title"
.=
_hd_title
_node_hyperdata
,
"Source"
.=
(
TE
.
encodeUtf8
<$>
_hd_source
_node_hyperdata
)
,
"Abstract"
.=
(
TE
.
encodeUtf8
<$>
_hd_abstract
_node_hyperdata
)
]
data
Ngrams
=
Ngrams
{
_ng_ngrams
::
[
Text
]
...
...
@@ -79,7 +92,7 @@ type API = Summary "Document Export"
:>
(
"json"
:>
Get
'[
J
SON
]
DocumentExport
:<|>
"csv"
:>
Get
'[
C
SV
]
[
Document
])
:>
Get
'[
P
lainText
]
Text
)
--
[Document])
$
(
deriveJSON
(
unPrefix
"_de_"
)
''
D
ocumentExport
)
$
(
deriveJSON
(
unPrefix
"_d_"
)
''
D
ocument
)
...
...
src/Gargantext/Core/Viz/Phylo/Legacy/LegacyAPI.hs
View file @
4baef92d
...
...
@@ -66,8 +66,8 @@ instance Show SVG where
instance
Accept
SVG
where
contentType
_
=
"SVG"
//
"image/svg+xml"
/:
(
"charset"
,
"utf-8"
)
instance
Show
a
=>
MimeRender
PlainText
a
where
mimeRender
_
val
=
cs
(
""
<>
show
val
)
--
instance Show a => MimeRender PlainText a where
--
mimeRender _ val = cs ("" <> show val)
instance
MimeRender
SVG
SVG
where
mimeRender
_
(
SVG
s
)
=
DBL
.
fromStrict
s
...
...
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