Refactor the subscription_list function

This commit is contained in:
Feng Lee 2017-11-19 01:15:22 +08:00
parent 8462fa8e89
commit 945f925136
1 changed files with 1 additions and 9 deletions

View File

@ -455,15 +455,7 @@ subscription_list(Key, PageNo, PageSize) when ?EMPTY_KEY(Key) ->
query_table(Qh, PageNo, PageSize, TotalNum);
subscription_list(Key, PageNo, PageSize) ->
Keys = ets:lookup(mqtt_subscription, Key),
Fun = case length(Keys) == 0 of
true ->
fun() -> ets:match_object(mqtt_subproperty, {{Key, '_'}, '_'}) end;
false ->
fun() ->
lists:map(fun({S, T}) ->[R] = ets:lookup(mqtt_subproperty, {T, S}), R end, Keys)
end
end,
Fun = fun() -> ets:match_object(mqtt_subproperty, {{'_', {Key, '_'}}, '_'}) end,
lookup_table(Fun, PageNo, PageSize).
route_list(Topic, PageNo, PageSize) when ?EMPTY_KEY(Topic) ->