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
4aaedab0
Commit
4aaedab0
authored
Dec 01, 2021
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[graphql] add ethercalc endpoint
parent
913ac007
Pipeline
#2194
failed with stage
in 10 minutes and 28 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
70 additions
and
0 deletions
+70
-0
Ethercalc.hs
src/Gargantext/API/GraphQL/Ethercalc.hs
+70
-0
No files found.
src/Gargantext/API/GraphQL/Ethercalc.hs
0 → 100644
View file @
4aaedab0
{-# OPTIONS_GHC -fno-warn-orphans #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# LANGUAGE DeriveAnyClass #-}
{-# LANGUAGE DuplicateRecordFields #-}
module
Gargantext.API.GraphQL.Ethercalc
where
import
Control.Lens
((
^.
))
import
Data.Either
(
Either
(
..
))
import
Data.Morpheus.Types
(
GQLType
,
Resolver
,
ResolverM
,
QUERY
,
lift
)
import
Data.Text
(
Text
)
import
qualified
Data.Text
as
T
import
Gargantext.API.Job
(
jobLogInit
)
import
qualified
Gargantext.API.Node.Corpus.New
as
New
import
Gargantext.API.Prelude
(
GargM
,
GargServerT
,
GargError
)
import
Gargantext.Core.Mail.Types
(
HasMail
)
import
Gargantext.Core.Types
(
NodeId
(
..
))
import
Gargantext.Database.Admin.Types.Node
(
NodeId
(
..
),
NodeType
)
import
Gargantext.Database.Admin.Types.Hyperdata
(
HyperdataFrame
,
getHyperdataFrameCSV
)
import
qualified
Gargantext.Database.Admin.Types.Node
as
NN
import
Gargantext.Database.Query.Table.Node
(
getClosestParentIdByType
,
getNode
,
getNodeWith
)
import
Gargantext.Database.Prelude
(
HasConnectionPool
,
HasConfig
)
import
qualified
Gargantext.Database.Schema.Node
as
N
import
Gargantext.Prelude
import
GHC.Generics
(
Generic
)
import
qualified
Prelude
as
Prelude
import
Servant
(
Proxy
(
..
))
import
Servant.Job.Async
(
serveJobsAPI
,
JobFunction
(
..
))
import
Text.Read
(
readEither
)
data
EthercalcCSVDownload
=
EthercalcCSVDownload
{
corpusId
::
Int
,
nodeId
::
Int
}
deriving
(
Show
,
Generic
,
GQLType
)
data
EthercalcCSVDownloadArgs
=
EthercalcCSVDownloadArgs
{
corpusId
::
Int
,
nodeId
::
Int
}
deriving
(
Generic
,
GQLType
)
type
GqlM
e
env
=
Resolver
QUERY
e
(
GargM
env
GargError
)
-- | Function to resolve user from a query.
ethercalcCSVDownload
::
(
HasConnectionPool
env
,
HasConfig
env
,
HasMail
env
)
=>
EthercalcCSVDownloadArgs
->
ResolverM
e
(
GargM
env
GargError
)
Int
ethercalcCSVDownload
(
EthercalcCSVDownloadArgs
{
corpusId
,
nodeId
})
=
do
ret
<-
lift
$
do
frameCalc
<-
getNodeWith
(
NodeId
nodeId
)
(
Proxy
::
Proxy
HyperdataFrame
)
printDebug
"[ethercalcCSVDownload] frameCalc"
frameCalc
csv
<-
liftBase
$
getHyperdataFrameCSV
(
frameCalc
^.
N
.
node_hyperdata
)
printDebug
"[ethercalcCSVDownload] csv"
csv
serveJobsAPI
$
JobFunction
(
\
i
log'
->
let
log''
x
=
do
printDebug
"[ethercalcCSVDownload] "
x
liftBase
$
log'
x
in
New
.
addToCorpusWithForm
user
corpusId
i
log''
(
jobLogInit
3
))
lift
$
printDebug
"[ethercalcCSVDownload] ret"
ret
pure
0
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