module Gargantext.API.Node.Corpus.New
where
-
import Conduit
import Control.Lens hiding (elements, Empty)
import Data.Aeson
-- import Test.QuickCheck (elements)
import Test.QuickCheck.Arbitrary
-import Gargantext.Prelude
-
import Gargantext.API.Admin.Orchestrator.Types (JobLog(..), AsyncJobs, ScraperEvent(..), scst_events)
import Gargantext.API.Admin.Types (HasSettings)
import Gargantext.API.Job (addEvent, jobLogSuccess, jobLogFailTotal)
import Gargantext.API.Node.Types
import Gargantext.Core (Lang(..){-, allLangs-})
import Gargantext.Core.Text.List.Social (FlowSocialListWith(..))
-import qualified Gargantext.Core.Text.Corpus.API as API
-import qualified Gargantext.Core.Text.Corpus.Parsers as Parser (FileType(..), parseFormatC)
import Gargantext.Core.Types.Individu (User(..))
import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger)
import Gargantext.Database.Action.Flow (flowCorpus, getDataText, flowDataText, TermType(..){-, allDataOrigins-})
import Gargantext.Database.Query.Table.Node (getNodeWith)
import Gargantext.Database.Query.Table.Node.UpdateOpaleye (updateHyperdata)
import Gargantext.Database.Schema.Node (node_hyperdata)
-import qualified Gargantext.Database.GargDB as GargDB
+import Gargantext.Prelude
import Gargantext.Prelude.Config (gc_max_docs_parsers)
+import qualified Gargantext.Core.Text.Corpus.API as API
+import qualified Gargantext.Core.Text.Corpus.Parsers as Parser (FileType(..), parseFormatC)
+import qualified Gargantext.Database.GargDB as GargDB
------------------------------------------------------------------------
{-
data Query = Query { query_query :: Text
------------------------------------------------------------------------
-- TODO WithQuery also has a corpus id
+
+
addToCorpusWithQuery :: FlowCmdM env err m
=> User
-> CorpusId
-- TODO if cid is folder -> create Corpus
-- if cid is corpus -> add to corpus
-- if cid is root -> create corpus in Private
+ printDebug "[G.A.N.C.New] getDataText with query" q
eTxts <- mapM (\db -> getDataText db (Multi l) q maybeLimit) [database2origin dbs]
+
let lTxts = lefts eTxts
+ printDebug "[G.A.N.C.New] lTxts" lTxts
case lTxts of
[] -> do
let txts = rights eTxts
}
(err:_) -> do
- pure $ addEvent "ERROR" (T.pack $ show err) $
- JobLog { _scst_succeeded = Just 2
- , _scst_failed = Just 1
- , _scst_remaining = Just 0
- , _scst_events = Just []
- }
+ printDebug "Error: " err
+ let jl = addEvent "ERROR" (T.pack $ show err) $
+ JobLog { _scst_succeeded = Just 2
+ , _scst_failed = Just 1
+ , _scst_remaining = Just 0
+ , _scst_events = Just []
+ }
+ logStatus jl
+ pure jl
type AddWithForm = Summary "Add with FormUrlEncoded to corpus endpoint"
--printDebug "Starting extraction : " cid
-- TODO granularity of the logStatus
+ printDebug "flowCorpus with lang" l
+
_cid' <- flowCorpus user
(Right [cid])
(Multi $ fromMaybe EN l)