Skip to content

Commit

Permalink
WHISTLE-717: allow caller id to come from stale views, and log when t…
Browse files Browse the repository at this point in the history
…he lookup failes with the reason
  • Loading branch information
k-anderson committed Nov 12, 2011
1 parent 8d22de9 commit ad6820e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions whistle_apps/apps/callflow/src/cf_attributes.erl
Expand Up @@ -88,7 +88,7 @@ caller_id(CIDType, DeviceId, OwnerId, #cf_call{account_id=AccountId, cid_number=
Property -> Property
end,
CIDNumber = wh_json:get_value(<<"number">>, CID, Num),
CIDName = wh_json:get_value(<<"name">>, CID, Num),
CIDName = wh_json:get_value(<<"name">>, CID, Name),
?LOG("using caller id ~s '~s'", [CIDNumber, CIDName]),
{CIDNumber, CIDName}
end.
Expand Down Expand Up @@ -257,13 +257,14 @@ fetch_attributes(Attribute, Expires, #cf_call{account_db=Db}) ->
{ok, Attributes} ->
Attributes;
{error, not_found} ->
case couch_mgr:get_all_results(Db, get_view(Attribute)) of
case couch_mgr:get_results(Db, get_view(Attribute), [{<<"stale">>, <<"ok">>}]) of
{ok, JObj} ->
Properties = [{wh_json:get_value(<<"key">>, Property), wh_json:get_value(<<"value">>, Property)}
|| Property <- JObj],
wh_cache:store({cf_attribute, Db, Attribute}, Properties, Expires),
Properties;
{error, _} ->
{error, R} ->
?LOG("unable to fetch attribute ~s: ~p", [Attribute, R]),
[]
end
end.
Expand Down

0 comments on commit ad6820e

Please sign in to comment.