Skip to content

Commit

Permalink
KAZOO-3245: Fix DBs order for whapps_maintenance refresh
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter Defebvre committed Jan 26, 2015
1 parent 192f389 commit 2f2f2fd
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions core/whistle_apps-1.0.0/src/whapps_maintenance.erl
Original file line number Diff line number Diff line change
Expand Up @@ -83,18 +83,13 @@ migrate() ->

-spec migrate(text() | integer()) -> 'no_return'.
migrate(Pause) ->
{'ok', Databases} = couch_mgr:db_info(),
Databases = get_databases(),
Accounts = [wh_util:format_account_id(Db, 'encoded')
|| Db <- Databases,
whapps_util:is_account_db(Db)
],
io:format("updating system dbs...~n"),
_ = refresh(?KZ_SYSTEM_DBS, Pause),

%% Ensure the views in each DB are update-to-date, depreciated view removed, sip_auth docs
%% that need to be aggregated have been, and the account definition is aggregated
io:format("updating views...~n"),
_ = refresh([Db || Db <- Databases, (not lists:member(Db, ?KZ_SYSTEM_DBS))], Pause),
io:format("updating dbs...~n"),
_ = refresh(Databases, Pause),

%% Remove depreciated dbs
io:format("removing depreciated databases...~n"),
Expand Down Expand Up @@ -125,7 +120,7 @@ blocking_refresh() -> refresh().

-spec blocking_refresh(text() | non_neg_integer()) -> 'no_return'.
blocking_refresh(Pause) ->
{'ok', Databases} = couch_mgr:db_info(),
Databases = get_databases(),
refresh(Databases, Pause).

%%--------------------------------------------------------------------
Expand All @@ -139,7 +134,7 @@ blocking_refresh(Pause) ->
-spec refresh(ne_binaries(), text() | non_neg_integer()) -> 'no_return'.
-spec refresh(ne_binaries(), non_neg_integer(), non_neg_integer()) -> 'no_return'.
refresh() ->
{'ok', Databases} = couch_mgr:db_info(),
Databases = get_databases(),
refresh(Databases, 2000).

refresh(Databases, Pause) ->
Expand All @@ -157,6 +152,11 @@ refresh([Database|Databases], Pause, Total) ->
end,
refresh(Databases, Pause, Total).

-spec get_databases() -> ne_binaries().
get_databases() ->
{'ok', Databases} = couch_mgr:db_info(),
?KZ_SYSTEM_DBS ++ [Db || Db <- Databases, (not lists:member(Db, ?KZ_SYSTEM_DBS))].

refresh(?WH_CONFIG_DB) ->
couch_mgr:db_create(?WH_CONFIG_DB);
refresh(?KZ_OAUTH_DB) ->
Expand Down Expand Up @@ -302,7 +302,7 @@ fetch_all_account_views() ->
%%--------------------------------------------------------------------
-spec remove_depreciated_databases() -> 'ok'.
remove_depreciated_databases() ->
{'ok', Databases} = couch_mgr:db_info(),
Databases = get_databases(),
remove_depreciated_databases(Databases).

-spec remove_depreciated_databases(ne_binaries()) -> 'ok'.
Expand Down

0 comments on commit 2f2f2fd

Please sign in to comment.