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
175
Issues
175
List
Board
Labels
Milestones
Merge Requests
10
Merge Requests
10
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
cf5f0c0b
Commit
cf5f0c0b
authored
Jan 15, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[API] upload
parent
7ad8c683
Pipeline
#687
canceled with stage
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
50 additions
and
0 deletions
+50
-0
API.hs
src/Gargantext/API.hs
+8
-0
New.hs
src/Gargantext/API/Corpus/New.hs
+42
-0
No files found.
src/Gargantext/API.hs
View file @
cf5f0c0b
...
...
@@ -285,6 +285,7 @@ type GargPrivateAPI' =
:<|>
New
.
AddWithQuery
:<|>
New
.
AddWithFile
:<|>
New
.
AddWithForm
-- :<|> "scraper" :> WithCallbacks ScraperAPI
-- :<|> "new" :> New.Api
...
...
@@ -366,6 +367,7 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
-- TODO access
:<|>
addWithQuery
:<|>
addWithFile
:<|>
addWithForm
-- :<|> addToCorpus
-- :<|> New.api uid -- TODO-SECURITY
-- :<|> New.info uid -- TODO-SECURITY
...
...
@@ -380,6 +382,12 @@ addWithFile cid i f =
serveJobsAPI
$
JobFunction
(
\
_i
log
->
New
.
addToCorpusWithFile
cid
i
f
(
liftIO
.
log
))
addWithForm
::
GargServer
New
.
AddWithForm
addWithForm
cid
=
serveJobsAPI
$
JobFunction
(
\
i
log
->
New
.
addToCorpusWithForm
cid
i
(
liftIO
.
log
))
serverStatic
::
Server
(
Get
'[
H
TML
]
Html
)
serverStatic
=
$
(
do
let
path
=
"purescript-gargantext/dist/index.html"
...
...
src/Gargantext/API/Corpus/New.hs
View file @
cf5f0c0b
...
...
@@ -153,6 +153,19 @@ instance FromJSON WithQuery where
instance
ToSchema
WithQuery
data
WithForm
=
WithForm
{
_wf_filetype
::
!
FileType
,
_wf_data
::
!
Text
}
deriving
Generic
makeLenses
''
W
ithForm
instance
FromJSON
WithForm
where
parseJSON
=
genericParseJSON
$
jsonOptions
"_wf_"
instance
ToSchema
WithForm
------------------------------------------------------------------------
type
AddAPI
withInput
=
AsyncJobsAPI
ScraperStatus
withInput
ScraperStatus
...
...
@@ -176,6 +189,15 @@ type AddWithFile = Summary "Add to corpus endpoint"
:>
"async"
:>
AddAPI
()
type
AddWithForm
=
Summary
"Add to corpus endpoint"
:>
"corpus"
:>
Capture
"corpus_id"
CorpusId
:>
"add"
:>
"form"
:>
"async"
:>
AddAPI
WithForm
------------------------------------------------------------------------
-- TODO WithQuery also has a corpus id
addToCorpusJobFunction
::
FlowCmdM
env
err
m
...
...
@@ -197,6 +219,7 @@ addToCorpusJobFunction _cid _input logStatus = do
,
_scst_events
=
Just
[]
}
addToCorpusWithFile
::
FlowCmdM
env
err
m
=>
CorpusId
->
MultipartData
Mem
...
...
@@ -217,3 +240,22 @@ addToCorpusWithFile cid input filetype logStatus = do
,
_scst_events
=
Just
[]
}
addToCorpusWithForm
::
FlowCmdM
env
err
m
=>
CorpusId
->
WithForm
->
(
ScraperStatus
->
m
()
)
->
m
ScraperStatus
addToCorpusWithForm
cid
(
WithForm
ft
d
)
logStatus
=
do
logStatus
ScraperStatus
{
_scst_succeeded
=
Just
10
,
_scst_failed
=
Just
2
,
_scst_remaining
=
Just
138
,
_scst_events
=
Just
[]
}
_h
<-
putStrLn
$
show
ft
pure
ScraperStatus
{
_scst_succeeded
=
Just
137
,
_scst_failed
=
Just
13
,
_scst_remaining
=
Just
0
,
_scst_events
=
Just
[]
}
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