aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorbadlop <badlop@process-one.net>2019-01-04 12:20:50 +0100
committerGitHub <noreply@github.com>2019-01-04 12:20:50 +0100
commit9631baaa634ff51e122de76a5550d716be549dca (patch)
treebcaad00881736d5ee20b718d0e9e3ee7037cccb2 /src
parentmod_mam: more checks for database failure (diff)
parentremove some chatty SQL queries by pulling back all groups with opts and filte... (diff)
Merge pull request #2599 from gardenia/master
Eliminate some repeated SQL queries [Issue #1656]
Diffstat (limited to 'src')
-rw-r--r--src/mod_shared_roster.erl28
1 files changed, 17 insertions, 11 deletions
diff --git a/src/mod_shared_roster.erl b/src/mod_shared_roster.erl
index 79b782e17..4cfaf48f7 100644
--- a/src/mod_shared_roster.erl
+++ b/src/mod_shared_roster.erl
@@ -303,10 +303,10 @@ get_jid_info({Subscription, Ask, Groups}, User, Server,
US1 = {U1, S1},
DisplayedGroups = get_user_displayed_groups(US),
SRUsers = lists:foldl(fun (Group, Acc1) ->
+ GroupName = get_group_name(LServer, Group),
lists:foldl(fun (User1, Acc2) ->
dict:append(User1,
- get_group_name(LServer,
- Group),
+ GroupName,
Acc2)
end,
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_special_users_groups(Host) ->
- lists:filter(fun (Group) ->
- get_group_opt(Host, Group, all_users, false) orelse
- get_group_opt(Host, Group, online_users, false)
- end,
- list_groups(Host)).
+ lists:filtermap(fun ({Group, Opts}) ->
+ case proplists:get_value(all_users, Opts, false) orelse
+ proplists:get_value(online_users, Opts, false) of
+ true -> {true, Group};
+ false -> false
+ end
+ end,
+ groups_with_opts(Host)).
%% Get list of names of groups that have @online@ in the memberlist
get_special_users_groups_online(Host) ->
- lists:filter(fun (Group) ->
- get_group_opt(Host, Group, online_users, false)
- end,
- list_groups(Host)).
+ lists:filtermap(fun ({Group, Opts}) ->
+ case proplists:get_value(online_users, Opts, false) of
+ true -> {true, Group};
+ false -> false
+ end
+ end,
+ groups_with_opts(Host)).
%% Given two lists of groupnames and their options,
%% return the list of displayed groups to the second list