import Data.Swagger
import Data.Text (Text)
import GHC.Generics (Generic)
-import Gargantext.API.Admin.Orchestrator.Types
-import Gargantext.Core (Lang(..))
-import Gargantext.Core.Utils.Prefix (unPrefixSwagger)
-import Gargantext.Database.Action.Flow (FlowCmdM) -- flowAnnuaire
-import Gargantext.Database.Admin.Types.Node (AnnuaireId)
-import Gargantext.Prelude
import Servant
import Servant.Job.Core
import Servant.Job.Types
import Servant.Job.Utils (jsonOptions)
import Web.FormUrlEncoded (FromForm)
-import qualified Gargantext.API.Node.Corpus.New.File as NewFile
+
+import qualified Gargantext.API.Node.Corpus.New.Types as NewTypes
+import Gargantext.API.Admin.Orchestrator.Types hiding (AsyncJobs)
+import Gargantext.Core (Lang(..))
+import Gargantext.Core.Utils.Prefix (unPrefixSwagger)
+import Gargantext.Database.Action.Flow.Types (FlowCmdM) -- flowAnnuaire
+import Gargantext.Database.Admin.Types.Node (AnnuaireId)
+import Gargantext.Prelude
type Api = Summary "New Annuaire endpoint"
------------------------------------------------------------------------
------------------------------------------------------------------------
data AnnuaireWithForm = AnnuaireWithForm
- { _wf_filetype :: !NewFile.FileType
+ { _wf_filetype :: !NewTypes.FileType
, _wf_data :: !Text
, _wf_lang :: !(Maybe Lang)
} deriving (Eq, Show, Generic)
instance FromForm AnnuaireWithForm
instance FromJSON AnnuaireWithForm where
parseJSON = genericParseJSON $ jsonOptions "_wf_"
+instance ToJSON AnnuaireWithForm where
+ toJSON = genericToJSON $ jsonOptions "_wf_"
+
instance ToSchema AnnuaireWithForm where
declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_wf_")
-> AnnuaireWithForm
-> (JobLog -> m ())
-> m JobLog
-addToAnnuaireWithForm _cid (AnnuaireWithForm ft _d _l) logStatus = do
-
- printDebug "ft" ft
+addToAnnuaireWithForm _cid (AnnuaireWithForm { _wf_filetype }) logStatus = do
- -- let
- -- parse = case ft of
- -- CSV_HAL -> Parser.parseFormat Parser.CsvHal
- -- CSV -> Parser.parseFormat Parser.CsvGargV3
- -- WOS -> Parser.parseFormat Parser.WOS
- -- PresseRIS -> Parser.parseFormat Parser.RisPresse
-
- -- docs <- liftBase
- -- $ splitEvery 500
- -- <$> take 1000000
- -- <$> parse (cs d)
+ printDebug "ft" _wf_filetype
logStatus JobLog { _scst_succeeded = Just 1
- , _scst_failed = Just 0
- , _scst_remaining = Just 1
- , _scst_events = Just []
- }
- -- cid' <- flowCorpus "user1"
- -- (Right [cid])
- -- (Multi $ fromMaybe EN l)
- -- (map (map toHyperdataDocument) docs)
-
- -- printDebug "cid'" cid'
-
+ , _scst_failed = Just 0
+ , _scst_remaining = Just 1
+ , _scst_events = Just []
+ }
pure JobLog { _scst_succeeded = Just 2
- , _scst_failed = Just 0
- , _scst_remaining = Just 0
- , _scst_events = Just []
- }
+ , _scst_failed = Just 0
+ , _scst_remaining = Just 0
+ , _scst_events = Just []
+ }