Commit f81fa897 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[FIX] merge

parents b13dfc93 f8ba5ba1
Pipeline #1691 passed with stage
in 35 minutes and 2 seconds
name: gargantext
version: '0.0.2.9.6'
version: '0.0.2.9.6.1'
synopsis: Search, map, share
description: Please see README.md
category: Data
......
......@@ -262,6 +262,7 @@ setListNgrams listId ngramsType ns = do
. something
)
)
printDebug "List modified" NodeList
saveRepo
......
......@@ -59,6 +59,62 @@ import Gargantext.Database.Schema.Node
import Gargantext.Database.Types (Indexed(..))
import Gargantext.Prelude
------------------------------------------------------------------------
{-
-- | TODO refactor
type API = Get '[JSON, HTML] (Headers '[Header "Content-Disposition" Text] NgramsList)
-- :<|> ReqBody '[JSON] NgramsList :> Post '[JSON] Bool
:<|> PostAPI
:<|> CSVPostAPI
api :: ListId -> GargServer API
api l = get l :<|> postAsync l :<|> csvPostAsync l
-}
----------------------
type GETAPI = Summary "Get List"
:> "lists"
:> Capture "listId" ListId
:> Get '[JSON, HTML] (Headers '[Header "Content-Disposition" Text] NgramsList)
getApi :: GargServer GETAPI
getApi = get
data HTML
instance Accept HTML where
contentType _ = "text" // "html" /: ("charset", "utf-8")
instance ToJSON a => MimeRender HTML a where
mimeRender _ = encode
----------------------
type JSONAPI = Summary "Update List"
:> "lists"
:> Capture "listId" ListId
:> "add"
:> "form"
:> "async"
:> AsyncJobs JobLog '[FormUrlEncoded] 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 '[FormUrlEncoded] WithTextFile JobLog
csvApi :: GargServer CSVAPI
csvApi = csvPostAsync
----------------------
------------------------------------------------------------------------
get :: RepoCmdM env err m =>
......@@ -87,6 +143,7 @@ post :: FlowCmdM env err m
-> m Bool
post l m = do
-- TODO check with Version for optim
printDebug "New list as file" l
_ <- mapM (\(nt, Versioned _v ns) -> setListNgrams l nt ns) $ toList m
-- TODO reindex
pure True
......@@ -163,10 +220,15 @@ type PostAPI = Summary "Update List"
:> "async"
:> AsyncJobs JobLog '[FormUrlEncoded] WithFile JobLog
postAsync :: ListId -> GargServer PostAPI
postAsync :: GargServer JSONAPI
postAsync lId =
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
=> ListId
......@@ -180,7 +242,9 @@ postAsync' l (WithFile _ m _) logStatus = do
, _scst_remaining = Just 1
, _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
, _scst_failed = Just 0
......@@ -223,14 +287,10 @@ csvPost l m = do
_ <- setListNgrams l NgramsTerms p
pure True
------------------------------------------------------------------------
type CSVPostAPI = Summary "Update List (legacy v3 CSV)"
:> "csv"
:> "add"
:> "form"
:> "async"
:> AsyncJobs JobLog '[FormUrlEncoded] WithTextFile JobLog
csvPostAsync :: ListId -> GargServer CSVPostAPI
csvPostAsync :: GargServer CSVAPI
csvPostAsync lId =
serveJobsAPI $
JobFunction $ \f@(WithTextFile ft _ n) log' -> do
......@@ -260,16 +320,3 @@ csvPostAsync' l (WithTextFile _ m _) logStatus = do
}
------------------------------------------------------------------------
type API = Get '[JSON, HTML] (Headers '[Header "Content-Disposition" Text] NgramsList)
-- :<|> ReqBody '[JSON] NgramsList :> Post '[JSON] Bool
:<|> PostAPI
:<|> CSVPostAPI
api :: ListId -> GargServer API
api l = get l :<|> postAsync l :<|> csvPostAsync l
data HTML
instance Accept HTML where
contentType _ = "text" // "html" /: ("charset", "utf-8")
instance ToJSON a => MimeRender HTML a where
mimeRender _ = encode
......@@ -160,9 +160,11 @@ type GargPrivateAPI' =
-- :<|> "scraper" :> WithCallbacks ScraperAPI
-- :<|> "new" :> New.Api
:<|> "lists" :> Summary "List export API"
:> Capture "listId" ListId
:> List.API
-- TODO refactor the 3 routes below
:<|> List.GETAPI
:<|> List.JSONAPI
:<|> List.CSVAPI
{-
:<|> "wait" :> Summary "Wait test"
:> Capture "x" Int
......@@ -237,7 +239,9 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
-- :<|> addAnnuaireWithForm
-- :<|> New.api uid -- TODO-SECURITY
-- :<|> New.info uid -- TODO-SECURITY
:<|> List.api
:<|> List.getApi
:<|> List.jsonApi
:<|> List.csvApi
-- :<|> waitAPI
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment