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
a3861819
Commit
a3861819
authored
Jul 23, 2021
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[API] splitting the routes (needs a code review of the api)
parent
1d2d97f9
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
11 deletions
+63
-11
Ngrams.hs
src/Gargantext/API/Ngrams.hs
+1
-0
List.hs
src/Gargantext/API/Ngrams/List.hs
+54
-7
Routes.hs
src/Gargantext/API/Routes.hs
+8
-4
No files found.
src/Gargantext/API/Ngrams.hs
View file @
a3861819
...
@@ -262,6 +262,7 @@ setListNgrams listId ngramsType ns = do
...
@@ -262,6 +262,7 @@ setListNgrams listId ngramsType ns = do
.
something
.
something
)
)
)
)
printDebug
"List modified"
NodeList
saveRepo
saveRepo
...
...
src/Gargantext/API/Ngrams/List.hs
View file @
a3861819
...
@@ -56,20 +56,59 @@ import Gargantext.Database.Types (Indexed(..))
...
@@ -56,20 +56,59 @@ import Gargantext.Database.Types (Indexed(..))
import
Gargantext.Prelude
import
Gargantext.Prelude
------------------------------------------------------------------------
------------------------------------------------------------------------
-- | TODO refactor
type
API
=
Get
'[
J
SON
,
HTML
]
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
type
API
=
Get
'[
J
SON
,
HTML
]
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
-- :<|> ReqBody '[JSON] NgramsList :> Post '[JSON] Bool
-- :<|> ReqBody '[JSON] NgramsList :> Post '[JSON] Bool
:<|>
PostAPI
:<|>
PostAPI
:<|>
CSVPostAPI
:<|>
CSVPostAPI
api
::
ListId
->
GargServer
API
api
l
=
get
l
:<|>
postAsync
l
:<|>
csvPostAsync
l
data
HTML
data
HTML
instance
Accept
HTML
where
instance
Accept
HTML
where
contentType
_
=
"text"
//
"html"
/:
(
"charset"
,
"utf-8"
)
contentType
_
=
"text"
//
"html"
/:
(
"charset"
,
"utf-8"
)
instance
ToJSON
a
=>
MimeRender
HTML
a
where
instance
ToJSON
a
=>
MimeRender
HTML
a
where
mimeRender
_
=
encode
mimeRender
_
=
encode
api
::
ListId
->
GargServer
API
api
l
=
get
l
:<|>
postAsync
l
:<|>
csvPostAsync
l
----------------------
type
GETAPI
=
Summary
"Get List"
:>
"lists"
:>
Capture
"listId"
ListId
:>
Get
'[
J
SON
,
HTML
]
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
getApi
::
GargServer
GETAPI
getApi
=
get
----------------------
type
JSONAPI
=
Summary
"Update List"
:>
"lists"
:>
Capture
"listId"
ListId
:>
"add"
:>
"form"
:>
"async"
:>
AsyncJobs
JobLog
'[
F
ormUrlEncoded
]
WithFile
JobLog
jsonApi
::
GargServer
JSONAPI
jsonApi
=
postAsync
----------------------
type
CSVAPI
=
Summary
"Update List (legacy v3 CSV)"
:>
"lists"
:>
Capture
"listId"
ListId
:>
"csv"
:>
"add"
:>
"form"
:>
"async"
:>
AsyncJobs
JobLog
'[
F
ormUrlEncoded
]
WithFile
JobLog
csvApi
::
GargServer
CSVAPI
csvApi
=
csvPostAsync
----------------------
------------------------------------------------------------------------
------------------------------------------------------------------------
get
::
RepoCmdM
env
err
m
=>
get
::
RepoCmdM
env
err
m
=>
ListId
->
m
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
ListId
->
m
(
Headers
'[
H
eader
"Content-Disposition"
Text
]
NgramsList
)
...
@@ -97,6 +136,7 @@ post :: FlowCmdM env err m
...
@@ -97,6 +136,7 @@ post :: FlowCmdM env err m
->
m
Bool
->
m
Bool
post
l
m
=
do
post
l
m
=
do
-- TODO check with Version for optim
-- TODO check with Version for optim
printDebug
"New list as file"
l
_
<-
mapM
(
\
(
nt
,
Versioned
_v
ns
)
->
setListNgrams
l
nt
ns
)
$
toList
m
_
<-
mapM
(
\
(
nt
,
Versioned
_v
ns
)
->
setListNgrams
l
nt
ns
)
$
toList
m
-- TODO reindex
-- TODO reindex
pure
True
pure
True
...
@@ -182,10 +222,15 @@ type PostAPI = Summary "Update List"
...
@@ -182,10 +222,15 @@ type PostAPI = Summary "Update List"
:>
"async"
:>
"async"
:>
AsyncJobs
JobLog
'[
F
ormUrlEncoded
]
WithFile
JobLog
:>
AsyncJobs
JobLog
'[
F
ormUrlEncoded
]
WithFile
JobLog
postAsync
::
ListId
->
GargServer
Post
API
postAsync
::
GargServer
JSON
API
postAsync
lId
=
postAsync
lId
=
serveJobsAPI
$
serveJobsAPI
$
JobFunction
(
\
f
log'
->
postAsync'
lId
f
(
liftBase
.
log'
))
JobFunction
(
\
f
log'
->
let
log''
x
=
do
printDebug
"postAsync ListId"
x
liftBase
$
log'
x
in
postAsync'
lId
f
log''
)
postAsync'
::
FlowCmdM
env
err
m
postAsync'
::
FlowCmdM
env
err
m
=>
ListId
=>
ListId
...
@@ -199,7 +244,9 @@ postAsync' l (WithFile _ m _) logStatus = do
...
@@ -199,7 +244,9 @@ postAsync' l (WithFile _ m _) logStatus = do
,
_scst_remaining
=
Just
1
,
_scst_remaining
=
Just
1
,
_scst_events
=
Just
[]
,
_scst_events
=
Just
[]
}
}
_r
<-
post
l
m
printDebug
"New list as file"
l
_
<-
post
l
m
-- printDebug "Done" r
pure
JobLog
{
_scst_succeeded
=
Just
1
pure
JobLog
{
_scst_succeeded
=
Just
1
,
_scst_failed
=
Just
0
,
_scst_failed
=
Just
0
...
@@ -214,7 +261,7 @@ type CSVPostAPI = Summary "Update List (legacy v3 CSV)"
...
@@ -214,7 +261,7 @@ type CSVPostAPI = Summary "Update List (legacy v3 CSV)"
:>
"async"
:>
"async"
:>
AsyncJobs
JobLog
'[
F
ormUrlEncoded
]
WithFile
JobLog
:>
AsyncJobs
JobLog
'[
F
ormUrlEncoded
]
WithFile
JobLog
csvPostAsync
::
ListId
->
GargServer
Post
API
csvPostAsync
::
GargServer
CSV
API
csvPostAsync
lId
=
csvPostAsync
lId
=
serveJobsAPI
$
serveJobsAPI
$
JobFunction
$
\
f
@
(
WithFile
ft
_
n
)
log'
->
do
JobFunction
$
\
f
@
(
WithFile
ft
_
n
)
log'
->
do
...
...
src/Gargantext/API/Routes.hs
View file @
a3861819
...
@@ -160,9 +160,11 @@ type GargPrivateAPI' =
...
@@ -160,9 +160,11 @@ type GargPrivateAPI' =
-- :<|> "scraper" :> WithCallbacks ScraperAPI
-- :<|> "scraper" :> WithCallbacks ScraperAPI
-- :<|> "new" :> New.Api
-- :<|> "new" :> New.Api
:<|>
"lists"
:>
Summary
"List export API"
-- TODO refactor the 3 routes below
:>
Capture
"listId"
ListId
:<|>
List
.
GETAPI
:>
List
.
API
:<|>
List
.
JSONAPI
:<|>
List
.
CSVAPI
{-
{-
:<|> "wait" :> Summary "Wait test"
:<|> "wait" :> Summary "Wait test"
:> Capture "x" Int
:> Capture "x" Int
...
@@ -237,7 +239,9 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
...
@@ -237,7 +239,9 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
-- :<|> addAnnuaireWithForm
-- :<|> addAnnuaireWithForm
-- :<|> New.api uid -- TODO-SECURITY
-- :<|> New.api uid -- TODO-SECURITY
-- :<|> New.info uid -- TODO-SECURITY
-- :<|> New.info uid -- TODO-SECURITY
:<|>
List
.
api
:<|>
List
.
getApi
:<|>
List
.
jsonApi
:<|>
List
.
csvApi
-- :<|> waitAPI
-- :<|> waitAPI
...
...
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