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
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
Christian Merten
haskell-gargantext
Commits
375c7d01
Commit
375c7d01
authored
Feb 16, 2023
by
Karen Konou
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Frame Write] Update API
parent
ca17a524
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
37 additions
and
9 deletions
+37
-9
DocumentsFromWriteNodes.hs
src/Gargantext/API/Node/DocumentsFromWriteNodes.hs
+37
-9
No files found.
src/Gargantext/API/Node/DocumentsFromWriteNodes.hs
View file @
375c7d01
...
@@ -12,6 +12,7 @@ Portability : POSIX
...
@@ -12,6 +12,7 @@ Portability : POSIX
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE MonoLocalBinds #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TemplateHaskell #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE TypeOperators #-}
{-# LANGUAGE ScopedTypeVariables #-}
module
Gargantext.API.Node.DocumentsFromWriteNodes
module
Gargantext.API.Node.DocumentsFromWriteNodes
where
where
...
@@ -19,6 +20,7 @@ module Gargantext.API.Node.DocumentsFromWriteNodes
...
@@ -19,6 +20,7 @@ module Gargantext.API.Node.DocumentsFromWriteNodes
-- import Data.Maybe (fromMaybe)
-- import Data.Maybe (fromMaybe)
import
Conduit
import
Conduit
import
Control.Lens
((
^.
))
import
Control.Lens
((
^.
))
import
Control.Monad
(
mzero
)
import
Data.Aeson
import
Data.Aeson
import
Data.Either
(
Either
(
..
),
rights
)
import
Data.Either
(
Either
(
..
),
rights
)
import
Data.Swagger
import
Data.Swagger
...
@@ -46,6 +48,9 @@ import Gargantext.Core.Text.Corpus.Parsers.Date (split')
...
@@ -46,6 +48,9 @@ import Gargantext.Core.Text.Corpus.Parsers.Date (split')
import
Servant
import
Servant
import
qualified
Data.List
as
List
import
qualified
Data.List
as
List
import
qualified
Data.Text
as
T
import
qualified
Data.Text
as
T
import
qualified
Data.Vector
as
V
import
qualified
Data.Scientific
as
Scientific
import
qualified
Prelude
-- import qualified Gargantext.Defaults as Defaults
-- import qualified Gargantext.Defaults as Defaults
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -56,7 +61,9 @@ data Params = Params
...
@@ -56,7 +61,9 @@ data Params = Params
{
id
::
Int
{
id
::
Int
,
paragraphs
::
Int
,
paragraphs
::
Int
,
lang
::
Lang
,
lang
::
Lang
,
selection
::
FlowSocialListWith
,
listSelection
::
FlowSocialListWith
,
nodeSelection
::
NodeSelection
,
recursive
::
Bool
}
}
deriving
(
Generic
,
Show
)
deriving
(
Generic
,
Show
)
instance
FromJSON
Params
where
instance
FromJSON
Params
where
...
@@ -64,6 +71,27 @@ instance FromJSON Params where
...
@@ -64,6 +71,27 @@ instance FromJSON Params where
instance
ToJSON
Params
where
instance
ToJSON
Params
where
toJSON
=
genericToJSON
defaultOptions
toJSON
=
genericToJSON
defaultOptions
instance
ToSchema
Params
instance
ToSchema
Params
data
NodeSelection
=
ChildNodes
|
SelectedNodes
[
ListId
]
deriving
(
Generic
,
Show
)
instance
FromJSON
NodeSelection
where
parseJSON
(
Object
v
)
=
do
typ
::
T
.
Text
<-
v
.:
"type"
value
<-
v
.:?
"value"
.!=
[]
case
typ
of
"ChildNodes"
->
pure
ChildNodes
"SelectedNodes"
->
pure
$
SelectedNodes
value
_
->
pure
ChildNodes
parseJSON
_
=
mzero
instance
ToJSON
NodeSelection
where
toJSON
ChildNodes
=
object
[
(
"type"
,
String
"ChildNodes"
)
]
toJSON
(
SelectedNodes
value
)
=
object
[
(
"type"
,
String
"SelectedNodes"
)
,
(
"value"
,
Array
$
V
.
fromList
$
map
(
\
(
NodeId
id
)
->
Number
$
Scientific
.
scientific
(
Prelude
.
toInteger
id
)
1
)
value
)]
instance
ToSchema
NodeSelection
where
declareNamedSchema
=
genericDeclareNamedSchemaUnrestricted
defaultSchemaOptions
------------------------------------------------------------------------
------------------------------------------------------------------------
api
::
UserId
->
NodeId
->
ServerT
API
(
GargM
Env
GargError
)
api
::
UserId
->
NodeId
->
ServerT
API
(
GargM
Env
GargError
)
api
uId
nId
=
api
uId
nId
=
...
@@ -79,7 +107,7 @@ documentsFromWriteNodes :: (HasSettings env, FlowCmdM env err m)
...
@@ -79,7 +107,7 @@ documentsFromWriteNodes :: (HasSettings env, FlowCmdM env err m)
->
Params
->
Params
->
(
JobLog
->
m
()
)
->
(
JobLog
->
m
()
)
->
m
JobLog
->
m
JobLog
documentsFromWriteNodes
uId
nId
Params
{
s
election
,
lang
,
paragraphs
}
logStatus
=
do
documentsFromWriteNodes
uId
nId
Params
{
listS
election
,
lang
,
paragraphs
}
logStatus
=
do
let
jobLog
=
JobLog
{
_scst_succeeded
=
Just
1
let
jobLog
=
JobLog
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
,
_scst_failed
=
Just
0
,
_scst_remaining
=
Just
1
,
_scst_remaining
=
Just
1
...
@@ -114,7 +142,7 @@ documentsFromWriteNodes uId nId Params { selection, lang, paragraphs } logStatus
...
@@ -114,7 +142,7 @@ documentsFromWriteNodes uId nId Params { selection, lang, paragraphs } logStatus
(
DataNew
(
Just
$
fromIntegral
$
length
parsed
,
yieldMany
parsed
))
(
DataNew
(
Just
$
fromIntegral
$
length
parsed
,
yieldMany
parsed
))
(
Multi
lang
)
(
Multi
lang
)
cId
cId
(
Just
s
election
)
(
Just
listS
election
)
logStatus
logStatus
pure
$
jobLogSuccess
jobLog
pure
$
jobLogSuccess
jobLog
...
...
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