Commit 722bd504 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[DEBUG] AddDocument

parent adee098c
...@@ -69,21 +69,31 @@ api :: UserId -> NodeId -> GargServer API ...@@ -69,21 +69,31 @@ api :: UserId -> NodeId -> GargServer API
api uId nId = api uId nId =
serveJobsAPI $ serveJobsAPI $
JobFunction (\q log' -> do JobFunction (\q log' -> do
documentUpload uId nId q (liftBase . log') documentUploadAsync uId nId q (liftBase . log')
) )
documentUpload :: (FlowCmdM env err m) documentUploadAsync :: (FlowCmdM env err m)
=> UserId => UserId
-> NodeId -> NodeId
-> DocumentUpload -> DocumentUpload
-> (JobLog -> m ()) -> (JobLog -> m ())
-> m JobLog -> m JobLog
documentUpload _uId nId doc logStatus = do documentUploadAsync _uId nId doc logStatus = do
let jl = JobLog { _scst_succeeded = Just 0 let jl = JobLog { _scst_succeeded = Just 0
, _scst_failed = Just 0 , _scst_failed = Just 0
, _scst_remaining = Just 1 , _scst_remaining = Just 1
, _scst_events = Just [] } , _scst_events = Just [] }
logStatus jl logStatus jl
_ <- documentUpload nId doc
pure $ jobLogSuccess jl
documentUpload :: (FlowCmdM env err m)
=> NodeId
-> DocumentUpload
-> m [DocId]
documentUpload nId doc = do
mcId <- getClosestParentIdByType' nId NodeCorpus mcId <- getClosestParentIdByType' nId NodeCorpus
let cId = case mcId of let cId = case mcId of
Just c -> c Just c -> c
...@@ -116,5 +126,6 @@ documentUpload _uId nId doc logStatus = do ...@@ -116,5 +126,6 @@ documentUpload _uId nId doc logStatus = do
docIds <- insertMasterDocs (Nothing :: Maybe HyperdataCorpus) (Multi EN) [hd] docIds <- insertMasterDocs (Nothing :: Maybe HyperdataCorpus) (Multi EN) [hd]
_ <- Doc.add cId docIds _ <- Doc.add cId docIds
pure docIds
pure $ jobLogSuccess jl
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