Commit a74ea59d authored by Grégoire Locqueville's avatar Grégoire Locqueville

Return Maybe (node ID) upon creating a subcorpus

parent f785e149
Pipeline #7070 canceled with stages
...@@ -22,11 +22,11 @@ makeSubcorpus :: ( HasNodeStoryEnv env ...@@ -22,11 +22,11 @@ makeSubcorpus :: ( HasNodeStoryEnv env
-> MakeSubcorpusAPI (AsServerT m) -> MakeSubcorpusAPI (AsServerT m)
makeSubcorpus user = MakeSubcorpusAPI $ \corpusId params -> do makeSubcorpus user = MakeSubcorpusAPI $ \corpusId params -> do
case parseQuery (RawQuery $ _subcorpusParams_query params) of case parseQuery (RawQuery $ _subcorpusParams_query params) of
Left _ -> return False Left _ -> return Nothing
Right q -> do Right q -> do
_ <- makeSubcorpusFromQuery subcorpusId <- makeSubcorpusFromQuery
(UserDBId user) (UserDBId user)
corpusId corpusId
q q
(_subcorpusParams_reuseParentList params) (_subcorpusParams_reuseParentList params)
return True return $ Just subcorpusId
...@@ -32,7 +32,7 @@ import Gargantext.API.Worker (WorkerAPI) ...@@ -32,7 +32,7 @@ import Gargantext.API.Worker (WorkerAPI)
import Gargantext.Core.Text.Ngrams (NgramsType(..)) import Gargantext.Core.Text.Ngrams (NgramsType(..))
import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger) import Gargantext.Core.Utils.Prefix (unPrefix, unPrefixSwagger)
import Gargantext.Database.Admin.Types.Node import Gargantext.Database.Admin.Types.Node
import Gargantext.Prelude (Bool) import Gargantext.Prelude (Bool, Maybe)
import Servant import Servant
-------------------------------------------------- --------------------------------------------------
...@@ -68,7 +68,7 @@ newtype MakeSubcorpusAPI mode = MakeSubcorpusAPI ...@@ -68,7 +68,7 @@ newtype MakeSubcorpusAPI mode = MakeSubcorpusAPI
:> Capture "corpus_id" CorpusId :> Capture "corpus_id" CorpusId
:> "subcorpus" :> "subcorpus"
:> ReqBody '[JSON] SubcorpusParams :> ReqBody '[JSON] SubcorpusParams
:> Post '[JSON] Bool -- was request successful :> Post '[JSON] (Maybe NodeId) -- new subcorpus ID, if successful
} deriving Generic } deriving Generic
data SubcorpusParams = SubcorpusParams data SubcorpusParams = SubcorpusParams
......
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