mirror of
https://github.com/processone/ejabberd.git
synced 2024-06-04 21:27:16 +02:00
Optimized mod_roster_odbc:get_roster
This commit is contained in:
parent
d673ff5fad
commit
15f664af26
|
@ -249,6 +249,11 @@ get_roster(LUser, LServer) ->
|
|||
_ ->
|
||||
[]
|
||||
end,
|
||||
GroupsDict =
|
||||
lists:foldl(
|
||||
fun({J, G}, Acc) ->
|
||||
dict:append(J, G, Acc)
|
||||
end, dict:new(), JIDGroups),
|
||||
RItems = lists:flatmap(
|
||||
fun(I) ->
|
||||
case raw_to_record(LServer, I) of
|
||||
|
@ -257,12 +262,11 @@ get_roster(LUser, LServer) ->
|
|||
[];
|
||||
R ->
|
||||
SJID = jlib:jid_to_string(R#roster.jid),
|
||||
Groups = lists:flatmap(
|
||||
fun({S, G}) when S == SJID ->
|
||||
[G];
|
||||
(_) ->
|
||||
[]
|
||||
end, JIDGroups),
|
||||
Groups =
|
||||
case dict:find(SJID, GroupsDict) of
|
||||
{ok, Gs} -> Gs;
|
||||
error -> []
|
||||
end,
|
||||
[R#roster{groups = Groups}]
|
||||
end
|
||||
end, Items),
|
||||
|
|
Loading…
Reference in New Issue
Block a user