Skip to content

Commit

Permalink
KAZOO-6066: new system config parameter to hydrate quantities during …
Browse files Browse the repository at this point in the history
…services cascade commit (2600hz#5596)

KAZOO-6066: make apis

KAZOO-6066: added description

KAZOO-6066: make apis
  • Loading branch information
k-anderson authored and jamesaimonetti committed Mar 22, 2019
1 parent aef9fec commit 28ccdd3
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions applications/crossbar/priv/api/swagger.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
14 changes: 13 additions & 1 deletion core/kazoo_services/src/kz_services.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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]) ->
Expand Down

0 comments on commit 28ccdd3

Please sign in to comment.