Commit cca441fb authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[ngrams] separate async ngrams chart update endpoint

parent 922bb0b8
Pipeline #1176 failed with stage
...@@ -349,14 +349,13 @@ tableNgramsPut tabType listId (Versioned p_version p_table) ...@@ -349,14 +349,13 @@ tableNgramsPut tabType listId (Versioned p_version p_table)
pure ret pure ret
tableNgramsPutAsync :: ( FlowCmdM env err m tableNgramsPostChartsAsync :: ( FlowCmdM env err m
, HasSettings env , HasSettings env
) )
=> UpdateTableNgrams => UpdateTableNgramsCharts
-> (JobLog -> m ()) -> (JobLog -> m ())
-> m JobLog -> m JobLog
tableNgramsPutAsync utn logStatus = do tableNgramsPostChartsAsync utn logStatus = do
-- let (Versioned p_version p_table) = utn ^. utn_patch
let tabType = utn ^. utn_tab_type let tabType = utn ^. utn_tab_type
let listId = utn ^. utn_list_id let listId = utn ^. utn_list_id
...@@ -658,8 +657,9 @@ type TableNgramsApi = TableNgramsApiGet ...@@ -658,8 +657,9 @@ type TableNgramsApi = TableNgramsApiGet
type TableNgramsAsyncApi = Summary "Table Ngrams Async API" type TableNgramsAsyncApi = Summary "Table Ngrams Async API"
:> "async" :> "async"
:> "charts"
:> "update" :> "update"
:> AsyncJobs JobLog '[JSON] UpdateTableNgrams JobLog :> AsyncJobs JobLog '[JSON] UpdateTableNgramsCharts JobLog
getTableNgramsCorpus :: (RepoCmdM env err m, HasNodeError err, HasConnectionPool env, HasConfig env) getTableNgramsCorpus :: (RepoCmdM env err m, HasNodeError err, HasConnectionPool env, HasConfig env)
=> NodeId => NodeId
...@@ -732,9 +732,9 @@ apiNgramsAsync _dId = ...@@ -732,9 +732,9 @@ apiNgramsAsync _dId =
JobFunction (\i l -> JobFunction (\i l ->
let let
log' x = do log' x = do
printDebug "tableNgramsPutAsync" x printDebug "tableNgramsPostChartsAsync" x
liftBase $ l x liftBase $ l x
in tableNgramsPutAsync i log') in tableNgramsPostChartsAsync i log')
-- Did the given list of ngrams changed since the given version? -- Did the given list of ngrams changed since the given version?
-- The returned value is versioned boolean value, meaning that one always retrieve the -- The returned value is versioned boolean value, meaning that one always retrieve the
......
...@@ -738,16 +738,15 @@ ngramsTypeFromTabType tabType = ...@@ -738,16 +738,15 @@ ngramsTypeFromTabType tabType =
-- TODO: This `panic` would disapear with custom NgramsType. -- TODO: This `panic` would disapear with custom NgramsType.
---- ----
-- PUT Async task -- Async task
data UpdateTableNgrams = UpdateTableNgrams data UpdateTableNgramsCharts = UpdateTableNgramsCharts
{ _utn_tab_type :: !TabType { _utn_tab_type :: !TabType
, _utn_list_id :: !ListId , _utn_list_id :: !ListId
, _utn_patch :: !(Versioned NgramsTablePatch)
} deriving (Eq, Show, Generic) } deriving (Eq, Show, Generic)
makeLenses ''UpdateTableNgrams makeLenses ''UpdateTableNgramsCharts
instance FromJSON UpdateTableNgrams where instance FromJSON UpdateTableNgramsCharts where
parseJSON = genericParseJSON $ jsonOptions "_utn_" parseJSON = genericParseJSON $ jsonOptions "_utn_"
instance ToSchema UpdateTableNgrams where instance ToSchema UpdateTableNgramsCharts where
declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_utn_") declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_utn_")
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