Merge pull request #2599 from gardenia/master

Eliminate some repeated SQL queries [Issue #1656]
This commit is contained in:
badlop 2019-01-04 12:20:50 +01:00 committed by GitHub
commit 9631baaa63
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 17 additions and 11 deletions

View File

@ -303,10 +303,10 @@ get_jid_info({Subscription, Ask, Groups}, User, Server,
US1 = {U1, S1}, US1 = {U1, S1},
DisplayedGroups = get_user_displayed_groups(US), DisplayedGroups = get_user_displayed_groups(US),
SRUsers = lists:foldl(fun (Group, Acc1) -> SRUsers = lists:foldl(fun (Group, Acc1) ->
GroupName = get_group_name(LServer, Group),
lists:foldl(fun (User1, Acc2) -> lists:foldl(fun (User1, Acc2) ->
dict:append(User1, dict:append(User1,
get_group_name(LServer, GroupName,
Group),
Acc2) Acc2)
end, end,
Acc1, Acc1,
@ -451,18 +451,24 @@ get_group_name(Host1, Group1) ->
%% Get list of names of groups that have @all@/@online@/etc in the memberlist %% Get list of names of groups that have @all@/@online@/etc in the memberlist
get_special_users_groups(Host) -> get_special_users_groups(Host) ->
lists:filter(fun (Group) -> lists:filtermap(fun ({Group, Opts}) ->
get_group_opt(Host, Group, all_users, false) orelse case proplists:get_value(all_users, Opts, false) orelse
get_group_opt(Host, Group, online_users, false) proplists:get_value(online_users, Opts, false) of
end, true -> {true, Group};
list_groups(Host)). false -> false
end
end,
groups_with_opts(Host)).
%% Get list of names of groups that have @online@ in the memberlist %% Get list of names of groups that have @online@ in the memberlist
get_special_users_groups_online(Host) -> get_special_users_groups_online(Host) ->
lists:filter(fun (Group) -> lists:filtermap(fun ({Group, Opts}) ->
get_group_opt(Host, Group, online_users, false) case proplists:get_value(online_users, Opts, false) of
end, true -> {true, Group};
list_groups(Host)). false -> false
end
end,
groups_with_opts(Host)).
%% Given two lists of groupnames and their options, %% Given two lists of groupnames and their options,
%% return the list of displayed groups to the second list %% return the list of displayed groups to the second list