Commit 43db884d authored by Alexandre Delanoë's avatar Alexandre Delanoë

Merge remote-tracking branch 'origin/622-dev-fix-for-first-commit-after-import' into dev

parents b70888af 0cdb214f
...@@ -39,7 +39,7 @@ import Gargantext.API.Node.Corpus.Types ...@@ -39,7 +39,7 @@ import Gargantext.API.Node.Corpus.Types
import Gargantext.API.Node.Corpus.Update (addLanguageToCorpus) import Gargantext.API.Node.Corpus.Update (addLanguageToCorpus)
import Gargantext.API.Node.Types import Gargantext.API.Node.Types
import Gargantext.Core (Lang(..), withDefaultLanguage, defaultLanguage) import Gargantext.Core (Lang(..), withDefaultLanguage, defaultLanguage)
import Gargantext.Core.NodeStory (HasNodeStoryImmediateSaver, HasNodeArchiveStoryImmediateSaver, currentVersion) import Gargantext.Core.NodeStory (HasNodeStoryImmediateSaver, HasNodeArchiveStoryImmediateSaver, currentVersion, NgramsStatePatch')
import Gargantext.Core.Text.Corpus.API qualified as API import Gargantext.Core.Text.Corpus.API qualified as API
import Gargantext.Core.Text.Corpus.Parsers qualified as Parser (FileType(..), parseFormatC) import Gargantext.Core.Text.Corpus.Parsers qualified as Parser (FileType(..), parseFormatC)
import Gargantext.Core.Text.List.Social (FlowSocialListWith(..)) import Gargantext.Core.Text.List.Social (FlowSocialListWith(..))
...@@ -51,7 +51,7 @@ import Gargantext.Database.Action.Mail (sendMail) ...@@ -51,7 +51,7 @@ import Gargantext.Database.Action.Mail (sendMail)
import Gargantext.Database.Action.Node (mkNodeWithParent) import Gargantext.Database.Action.Node (mkNodeWithParent)
import Gargantext.Database.Action.User (getUserId) import Gargantext.Database.Action.User (getUserId)
import Gargantext.Database.Admin.Types.Hyperdata import Gargantext.Database.Admin.Types.Hyperdata
import Gargantext.Database.Admin.Types.Node (CorpusId, NodeType(..)) import Gargantext.Database.Admin.Types.Node (CorpusId, NodeType(..), ParentId)
import Gargantext.Database.GargDB qualified as GargDB import Gargantext.Database.GargDB qualified as GargDB
import Gargantext.Database.Prelude (hasConfig) import Gargantext.Database.Prelude (hasConfig)
import Gargantext.Database.Query.Table.Node (getNodeWith, getOrMkList) import Gargantext.Database.Query.Table.Node (getNodeWith, getOrMkList)
...@@ -252,10 +252,7 @@ addToCorpusWithQuery user cid (WithQuery { _wq_query = q ...@@ -252,10 +252,7 @@ addToCorpusWithQuery user cid (WithQuery { _wq_query = q
corpusId <- flowDataText user txt (Multi l) cid (Just flw) jobHandle corpusId <- flowDataText user txt (Multi l) cid (Just flw) jobHandle
$(logLocM) DEBUG $ T.pack $ "corpus id " <> show corpusId $(logLocM) DEBUG $ T.pack $ "corpus id " <> show corpusId
userId <- getUserId user _ <- commitCorpus cid user
listId <- getOrMkList cid userId
v <- currentVersion listId
_ <- commitStatePatch listId (Versioned v mempty)
-- printDebug "sending email" ("xxxxxxxxxxxxxxxxxxxxx" :: Text) -- printDebug "sending email" ("xxxxxxxxxxxxxxxxxxxxx" :: Text)
sendMail user sendMail user
...@@ -275,7 +272,10 @@ type AddWithForm = Summary "Add with FormUrlEncoded to corpus endpoint" ...@@ -275,7 +272,10 @@ type AddWithForm = Summary "Add with FormUrlEncoded to corpus endpoint"
:> "async" :> "async"
:> AsyncJobs JobLog '[FormUrlEncoded] NewWithForm JobLog :> AsyncJobs JobLog '[FormUrlEncoded] NewWithForm JobLog
addToCorpusWithForm :: (FlowCmdM env err m, MonadJobStatus m) addToCorpusWithForm :: ( FlowCmdM env err m
, MonadJobStatus m
, HasNodeStoryImmediateSaver env
, HasNodeArchiveStoryImmediateSaver env )
=> User => User
-> CorpusId -> CorpusId
-> NewWithForm -> NewWithForm
...@@ -344,6 +344,8 @@ addToCorpusWithForm user cid nwf jobHandle = do ...@@ -344,6 +344,8 @@ addToCorpusWithForm user cid nwf jobHandle = do
--(map (map toHyperdataDocument) docs) --(map (map toHyperdataDocument) docs)
jobHandle jobHandle
_ <- commitCorpus cid user
-- printDebug "Extraction finished : " cid -- printDebug "Extraction finished : " cid
-- printDebug "sending email" ("xxxxxxxxxxxxxxxxxxxxx" :: Text) -- printDebug "sending email" ("xxxxxxxxxxxxxxxxxxxxx" :: Text)
-- TODO uncomment this -- TODO uncomment this
...@@ -422,3 +424,17 @@ addToCorpusWithFile user cid nwf@(NewWithFile _d (withDefaultLanguage -> l) fNam ...@@ -422,3 +424,17 @@ addToCorpusWithFile user cid nwf@(NewWithFile _d (withDefaultLanguage -> l) fNam
sendMail user sendMail user
markComplete jobHandle markComplete jobHandle
--- UTILITIES
commitCorpus :: ( FlowCmdM env err m
, HasNodeArchiveStoryImmediateSaver env
, HasNodeStoryImmediateSaver env )
=> ParentId -> User -> m (Versioned NgramsStatePatch')
commitCorpus cid user = do
userId <- getUserId user
listId <- getOrMkList cid userId
v <- currentVersion listId
commitStatePatch listId (Versioned v mempty)
...@@ -35,6 +35,7 @@ import Gargantext.API.Node.Corpus.New.Types (FileFormat(..), FileType(..)) ...@@ -35,6 +35,7 @@ import Gargantext.API.Node.Corpus.New.Types (FileFormat(..), FileType(..))
import Gargantext.API.Node.Types (NewWithForm(..)) import Gargantext.API.Node.Types (NewWithForm(..))
import Gargantext.API.Prelude import Gargantext.API.Prelude
import Gargantext.Core (Lang) import Gargantext.Core (Lang)
import Gargantext.Core.NodeStory (HasNodeArchiveStoryImmediateSaver)
import Gargantext.Core.Text.List.Social (FlowSocialListWith(..)) import Gargantext.Core.Text.List.Social (FlowSocialListWith(..))
import Gargantext.Core.Types.Individu (User(..)) import Gargantext.Core.Types.Individu (User(..))
import Gargantext.Database.Action.Flow.Types import Gargantext.Database.Action.Flow.Types
...@@ -70,7 +71,10 @@ api authenticatedUser nId = ...@@ -70,7 +71,10 @@ api authenticatedUser nId =
frameCalcUploadAsync :: (HasConfig env, FlowCmdM env err m, MonadJobStatus m) frameCalcUploadAsync :: ( HasConfig env
, FlowCmdM env err m
, MonadJobStatus m
, HasNodeArchiveStoryImmediateSaver env )
=> AuthenticatedUser => AuthenticatedUser
-- ^ The logged-in user -- ^ The logged-in user
-> NodeId -> NodeId
......
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