diff --git a/applications/crossbar/priv/api/swagger.json b/applications/crossbar/priv/api/swagger.json index 1d712df7b72..c9b1bfef1a3 100644 --- a/applications/crossbar/priv/api/swagger.json +++ b/applications/crossbar/priv/api/swagger.json @@ -33741,6 +33741,11 @@ "description": "services get_items_from_quantities", "type": "boolean" }, + "hydrate_cascade_commits": { + "default": true, + "description": "When an account makes a change it triggers a propagation up the account hiearchy updating the cascade quantities, if this is set to false the cascade quantities are summed with the account update deltas. If this is set to true then the views will be invoked to fully reconcile the quantities (hydrate) during the cascade commits, a more expensive DB operation but provides self-corrective quantities.", + "type": "boolean" + }, "master_account_bookkeeper": { "default": "kz_bookkeeper_local", "description": "services master account bookkeeper", diff --git a/applications/crossbar/priv/couchdb/schemas/system_config.services.json b/applications/crossbar/priv/couchdb/schemas/system_config.services.json index 1119c493aa1..e72aefb4c87 100644 --- a/applications/crossbar/priv/couchdb/schemas/system_config.services.json +++ b/applications/crossbar/priv/couchdb/schemas/system_config.services.json @@ -27,6 +27,11 @@ "description": "services get_items_from_quantities", "type": "boolean" }, + "hydrate_cascade_commits": { + "default": true, + "description": "When an account makes a change it triggers a propagation up the account hiearchy updating the cascade quantities, if this is set to false the cascade quantities are summed with the account update deltas. If this is set to true then the views will be invoked to fully reconcile the quantities (hydrate) during the cascade commits, a more expensive DB operation but provides self-corrective quantities.", + "type": "boolean" + }, "master_account_bookkeeper": { "default": "kz_bookkeeper_local", "description": "services master account bookkeeper", diff --git a/core/kazoo_services/src/kz_services.erl b/core/kazoo_services/src/kz_services.erl index a7718d88974..ab67a5e198e 100644 --- a/core/kazoo_services/src/kz_services.erl +++ b/core/kazoo_services/src/kz_services.erl @@ -826,10 +826,22 @@ commit_updates(Services, FetchOptions) -> 'false' -> UpdatedServices; 'true' -> Tree = lists:reverse(kzd_services:tree(services_jobj(Services))), - _ = cascade_commit_updates(FetchOptions, Tree), + CascadeFetchOptions = cascade_commits_fetch_options(FetchOptions), + _ = cascade_commit_updates(CascadeFetchOptions, Tree), UpdatedServices end. +-spec cascade_commits_fetch_options(kz_term:proplist()) -> kz_term:proplist(). +cascade_commits_fetch_options(FetchOptions) -> + case kapps_config:get_is_true(?CONFIG_CAT, <<"hydrate_cascade_commits">>, 'true') of + 'false' -> FetchOptions; + 'true' -> + ['hydrate_cascade_quantities' + ,'hydrate_account_quantities' + | FetchOptions + ] + end. + -spec cascade_commit_updates(kz_term:proplist(), kz_term:ne_binaries()) -> 'ok'. cascade_commit_updates(_FetchOptions, []) -> 'ok'; cascade_commit_updates(FetchOptions, [Account|Accounts]) ->