[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'' let jl = JobLog { _scst_succeeded = Just 0
printDebug "[csvPostAsync] job ended with joblog: " jl , _scst_failed = Just 0
, _scst_remaining = Just 1
, _scst_events = Just []
}
log'' jl log'' jl
pure jl ePost <- csvPost lId (_wtf_data f)
let jlNew = case ePost of
Left err -> jobLogFailTotalWithMessage err jl
csvPostAsync' :: FlowCmdM env err m Right () -> jobLogSuccess jl
=> ListId printDebug "[csvPostAsync] job ended with joblog: " jlNew
-> WithTextFile log'' jlNew
-> (JobLog -> m ()) pure jlNew
-> m JobLog
csvPostAsync' l (WithTextFile _ m _) logStatus = do
let jl = JobLog { _scst_succeeded = Just 0
, _scst_failed = Just 0
, _scst_remaining = Just 1
, _scst_events = Just []
}
logStatus jl
ePost <- csvPost l m
case ePost of
Left err -> pure $ jobLogFailTotalWithMessage err jl
Right () -> 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