Skip to content

Commit

Permalink
KAZOO-2977: formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesaimonetti committed Sep 26, 2014
1 parent 1275456 commit 3d0b986
Showing 1 changed file with 13 additions and 16 deletions.
29 changes: 13 additions & 16 deletions core/whistle_services-1.0.0/src/services/wh_service_devices.erl
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
%%%-------------------------------------------------------------------
%%% @copyright (C) 2012-2013, 2600Hz, INC
%%% @copyright (C) 2012-2014, 2600Hz, INC
%%% @doc
%%%
%%% @end
Expand All @@ -19,6 +19,7 @@
%% @end
%%--------------------------------------------------------------------
-spec reconcile(wh_services:services()) -> wh_services:services().
-spec reconcile(wh_services:services(), ne_binary()) -> wh_services:services().
reconcile(Services) ->
AccountId = wh_services:account_id(Services),
AccountDb = wh_util:format_account_id(AccountId, 'encoded'),
Expand Down Expand Up @@ -51,24 +52,20 @@ reconcile(Services, DeviceType) ->
{'ok', []} -> wh_services:reset_category(<<"devices">>, Services);
{'ok', JObjs} ->
S = lists:foldl(
fun(JObj, S) ->
Item = wh_json:get_value(<<"key">>, JObj),
Quantity = wh_json:get_integer_value(<<"value">>, JObj, 0),
case Item =:= DeviceType of
'false' -> wh_services:update(<<"devices">>, Item, Quantity, S);
'true' -> wh_services:update(<<"devices">>, Item, Quantity+1, S)
end
end
,wh_services:reset_category(<<"devices">>, Services)
,JObjs
),
fun(JObj, S) ->
Item = wh_json:get_value(<<"key">>, JObj),
Quantity = wh_json:get_integer_value(<<"value">>, JObj, 0),
case Item =:= DeviceType of
'false' -> wh_services:update(<<"devices">>, Item, Quantity, S);
'true' -> wh_services:update(<<"devices">>, Item, Quantity+1, S)
end
end
,wh_services:reset_category(<<"devices">>, Services)
,JObjs
),
Keys = couch_mgr:get_result_keys(JObjs),
case lists:member(DeviceType, Keys) of
'false' -> wh_services:update(<<"devices">>, DeviceType, 1, S);
'true' -> S
end
end.




0 comments on commit 3d0b986

Please sign in to comment.