[list] refactoring of csv post

parent ce5d8d25
...@@ -292,33 +292,25 @@ csvPost l m = do ...@@ -292,33 +292,25 @@ csvPost l m = do
------------------------------------------------------------------------ ------------------------------------------------------------------------
csvPostAsync :: ServerT CSVAPI (GargM Env GargError) csvPostAsync :: ServerT CSVAPI (GargM Env GargError)
csvPostAsync lId = csvPostAsync lId =
serveJobsAPI UpdateNgramsListJobCSV $ \jHandle f@(WithTextFile _ft _ _n) -> do serveJobsAPI UpdateNgramsListJobCSV $ \jHandle f -> do
let log'' x = do let log'' x = do
-- printDebug "[csvPostAsync] filetype" ft -- printDebug "[csvPostAsync] filetype" (_wtf_filetype f)
-- printDebug "[csvPostAsync] name" n -- printDebug "[csvPostAsync] name" (_wtf_name f)
jobHandleLogger jHandle x jobHandleLogger jHandle x
jl <- csvPostAsync' lId f log''
printDebug "[csvPostAsync] job ended with joblog: " jl
log'' jl
pure jl
csvPostAsync' :: FlowCmdM env err m
=> ListId
-> WithTextFile
-> (JobLog -> m ())
-> m JobLog
csvPostAsync' l (WithTextFile _ m _) 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 log'' jl
ePost <- csvPost l m ePost <- csvPost lId (_wtf_data f)
case ePost of let jlNew = case ePost of
Left err -> pure $ jobLogFailTotalWithMessage err jl Left err -> jobLogFailTotalWithMessage err jl
Right () -> pure $ jobLogSuccess jl Right () -> jobLogSuccess jl
printDebug "[csvPostAsync] job ended with joblog: " jlNew
log'' jlNew
pure jlNew
------------------------------------------------------------------------ ------------------------------------------------------------------------
......
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