mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
Optimize sql queries in pubsub select_affiliation_subscriptions
This commit is contained in:
parent
2d32c66fd7
commit
fdb7e3e3fa
@ -894,10 +894,23 @@ select_affiliation_subscriptions(Nidx, JID) ->
|
|||||||
select_affiliation_subscriptions(Nidx, JID, JID) ->
|
select_affiliation_subscriptions(Nidx, JID, JID) ->
|
||||||
select_affiliation_subscriptions(Nidx, JID);
|
select_affiliation_subscriptions(Nidx, JID);
|
||||||
select_affiliation_subscriptions(Nidx, GenKey, SubKey) ->
|
select_affiliation_subscriptions(Nidx, GenKey, SubKey) ->
|
||||||
{result, Affiliation} = get_affiliation(Nidx, GenKey),
|
GJ = encode_jid(GenKey),
|
||||||
{result, BareJidSubs} = get_subscriptions(Nidx, GenKey),
|
SJ = encode_jid(SubKey),
|
||||||
{result, FullJidSubs} = get_subscriptions(Nidx, SubKey),
|
case catch
|
||||||
{Affiliation, BareJidSubs++FullJidSubs}.
|
ejabberd_sql:sql_query_t(
|
||||||
|
?SQL("select jid = %(GJ)s as @(G)d, @(affiliation)s, @(subscriptions)s from "
|
||||||
|
" pubsub_state where nodeid=%(Nidx)d and jid in (%(GJ)s, %(SJ)s)"))
|
||||||
|
of
|
||||||
|
{selected, Res} ->
|
||||||
|
lists:foldr(
|
||||||
|
fun({1, A, S}, {_, Subs}) ->
|
||||||
|
{decode_affiliation(A), Subs ++ decode_subscriptions(S)};
|
||||||
|
({_, _, S}, {Aff, Subs}) ->
|
||||||
|
{Aff, Subs ++ decode_subscriptions(S)}
|
||||||
|
end, {none, []}, Res);
|
||||||
|
_ ->
|
||||||
|
{none, []}
|
||||||
|
end.
|
||||||
|
|
||||||
update_affiliation(Nidx, JID, Affiliation) ->
|
update_affiliation(Nidx, JID, Affiliation) ->
|
||||||
J = encode_jid(JID),
|
J = encode_jid(JID),
|
||||||
|
Loading…
Reference in New Issue
Block a user