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
cf5f0c0b
Commit
cf5f0c0b
authored
Jan 15, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[API] upload
parent
7ad8c683
Changes
2
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' =
...
@@ -285,6 +285,7 @@ type GargPrivateAPI' =
:<|>
New
.
AddWithQuery
:<|>
New
.
AddWithQuery
:<|>
New
.
AddWithFile
:<|>
New
.
AddWithFile
:<|>
New
.
AddWithForm
-- :<|> "scraper" :> WithCallbacks ScraperAPI
-- :<|> "scraper" :> WithCallbacks ScraperAPI
-- :<|> "new" :> New.Api
-- :<|> "new" :> New.Api
...
@@ -366,6 +367,7 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
...
@@ -366,6 +367,7 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
-- TODO access
-- TODO access
:<|>
addWithQuery
:<|>
addWithQuery
:<|>
addWithFile
:<|>
addWithFile
:<|>
addWithForm
-- :<|> addToCorpus
-- :<|> addToCorpus
-- :<|> New.api uid -- TODO-SECURITY
-- :<|> New.api uid -- TODO-SECURITY
-- :<|> New.info uid -- TODO-SECURITY
-- :<|> New.info uid -- TODO-SECURITY
...
@@ -380,6 +382,12 @@ addWithFile cid i f =
...
@@ -380,6 +382,12 @@ addWithFile cid i f =
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
_i
log
->
New
.
addToCorpusWithFile
cid
i
f
(
liftIO
.
log
))
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
::
Server
(
Get
'[
H
TML
]
Html
)
serverStatic
=
$
(
do
serverStatic
=
$
(
do
let
path
=
"purescript-gargantext/dist/index.html"
let
path
=
"purescript-gargantext/dist/index.html"
...
...
src/Gargantext/API/Corpus/New.hs
View file @
cf5f0c0b
...
@@ -153,6 +153,19 @@ instance FromJSON WithQuery where
...
@@ -153,6 +153,19 @@ instance FromJSON WithQuery where
instance
ToSchema
WithQuery
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
type
AddAPI
withInput
=
AsyncJobsAPI
ScraperStatus
withInput
ScraperStatus
AddAPI
withInput
=
AsyncJobsAPI
ScraperStatus
withInput
ScraperStatus
...
@@ -176,6 +189,15 @@ type AddWithFile = Summary "Add to corpus endpoint"
...
@@ -176,6 +189,15 @@ type AddWithFile = Summary "Add to corpus endpoint"
:>
"async"
:>
"async"
:>
AddAPI
()
:>
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
-- TODO WithQuery also has a corpus id
addToCorpusJobFunction
::
FlowCmdM
env
err
m
addToCorpusJobFunction
::
FlowCmdM
env
err
m
...
@@ -197,6 +219,7 @@ addToCorpusJobFunction _cid _input logStatus = do
...
@@ -197,6 +219,7 @@ addToCorpusJobFunction _cid _input logStatus = do
,
_scst_events
=
Just
[]
,
_scst_events
=
Just
[]
}
}
addToCorpusWithFile
::
FlowCmdM
env
err
m
addToCorpusWithFile
::
FlowCmdM
env
err
m
=>
CorpusId
=>
CorpusId
->
MultipartData
Mem
->
MultipartData
Mem
...
@@ -217,3 +240,22 @@ addToCorpusWithFile cid input filetype logStatus = do
...
@@ -217,3 +240,22 @@ addToCorpusWithFile cid input filetype logStatus = do
,
_scst_events
=
Just
[]
,
_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