import Servant
import Servant.Auth as SA
import Servant.Auth.Swagger ()
-import Servant.Job.Async
import Servant.Swagger.UI
import Gargantext.API.Admin.Auth (ForgotPasswordAPI, ForgotPasswordAsyncAPI, withAccess)
import Gargantext.API.Admin.Auth.Types (AuthRequest, AuthResponse, AuthenticatedUser(..), PathId(..))
+import Gargantext.API.Admin.EnvTypes (Env, GargJob(..))
import Gargantext.API.Admin.FrontEnd (FrontEndAPI)
import Gargantext.API.Context
import Gargantext.API.Count (CountAPI, count, Query)
import Gargantext.Database.Prelude (HasConfig(..))
import Gargantext.Prelude
import Gargantext.Prelude.Config (gc_max_docs_scrapers)
+import Gargantext.Utils.Jobs (serveJobsAPI)
import qualified Gargantext.API.GraphQL as GraphQL
import qualified Gargantext.API.Ngrams.List as List
import qualified Gargantext.API.Node.Contact as Contact
:<|> nodesAPI
-serverPrivateGargAPI' :: AuthenticatedUser -> GargServer GargPrivateAPI'
+serverPrivateGargAPI'
+ :: AuthenticatedUser -> ServerT GargPrivateAPI' (GargM Env GargError)
serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
= serverGargAdminAPI
:<|> nodeAPI (Proxy :: Proxy HyperdataAny) uid
pure $ "Waited: " <> (cs $ show n)
----------------------------------------
-addCorpusWithQuery :: User -> GargServer New.AddWithQuery
+addCorpusWithQuery :: User -> ServerT New.AddWithQuery (GargM Env GargError)
addCorpusWithQuery user cid =
- serveJobsAPI $
- JobFunction (\q log' -> do
- limit <- view $ hasConfig . gc_max_docs_scrapers
- New.addToCorpusWithQuery user cid q (Just limit) (liftBase . log')
+ serveJobsAPI AddCorpusQueryJob $ \q log' -> do
+ limit <- view $ hasConfig . gc_max_docs_scrapers
+ New.addToCorpusWithQuery user cid q (Just limit) (liftBase . log')
{- let log' x = do
printDebug "addToCorpusWithQuery" x
liftBase $ log x
-}
- )
-{-
-addWithFile :: GargServer New.AddWithFile
-addWithFile cid i f =
- serveJobsAPI $
- JobFunction (\_i log -> New.addToCorpusWithFile cid i f (liftBase . log))
--}
-
-addCorpusWithForm :: User -> GargServer New.AddWithForm
+addCorpusWithForm :: User -> ServerT New.AddWithForm (GargM Env GargError)
addCorpusWithForm user cid =
- serveJobsAPI $
- JobFunction (\i log' ->
+ serveJobsAPI AddCorpusFormJob $ \i log' ->
let
log'' x = do
- printDebug "[addToCorpusWithForm] " x
+ --printDebug "[addToCorpusWithForm] " x
liftBase $ log' x
- in New.addToCorpusWithForm user cid i log'' (jobLogInit 3))
+ in New.addToCorpusWithForm user cid i log'' (jobLogInit 3)
-addCorpusWithFile :: User -> GargServer New.AddWithFile
+addCorpusWithFile :: User -> ServerT New.AddWithFile (GargM Env GargError)
addCorpusWithFile user cid =
- serveJobsAPI $
- JobFunction (\i log' ->
+ serveJobsAPI AddCorpusFileJob $ \i log' ->
let
log'' x = do
printDebug "[addToCorpusWithFile]" x
liftBase $ log' x
- in New.addToCorpusWithFile user cid i log'')
+ in New.addToCorpusWithFile user cid i log''
-addAnnuaireWithForm :: GargServer Annuaire.AddWithForm
+addAnnuaireWithForm :: ServerT Annuaire.AddWithForm (GargM Env GargError)
addAnnuaireWithForm cid =
- serveJobsAPI $
- JobFunction (\i log' -> Annuaire.addToAnnuaireWithForm cid i (liftBase . log'))
-
+ serveJobsAPI AddAnnuaireFormJob $ \i log' ->
+ Annuaire.addToAnnuaireWithForm cid i (liftBase . log')