Commit ee8dfef5 authored by legoktm's avatar legoktm Committed by Abhilash Raj
Browse files

Optimize MembershipManager.memberships_pending_warning()

parent b0453264
......@@ -58,6 +58,8 @@ Bugs
the owner if the target is both an owner and moderator. (Closes #888)
* Command runner now handles RFC 2047 encoded command with non-ascii prefix.
(Closes #858)
* Improve performance of the bounce runner by decreasing the number of
database queries executed.
Command line
------------
......
......@@ -240,7 +240,9 @@ class MembershipManager:
# could have been reset due to bounce info getting stale. We will send
# warnings to people who have been disabled already, regardless of
# their bounce score. Same is true below for removal.
query = store.query(Member).join(
query = store.query(
Member,
MailingList.bounce_you_are_disabled_warnings_interval).join(
MailingList, Member.list_id == MailingList._list_id).join(
Member.preferences).filter(and_(
MailingList.process_bounces == True, # noqa: E712
......@@ -259,9 +261,8 @@ class MembershipManager:
# func.DATETIME(MailingList.bounce_you_are_disabled_warnings_interval))
# < func.DATETIME(now())))
for member in query.all():
if (member.last_warning_sent +
member.mailing_list.bounce_you_are_disabled_warnings_interval) <= now(): # noqa: E501
for member, interval in query.all():
if (member.last_warning_sent + interval) <= now():
yield member
@dbconnection
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment