Abhilash Raj pushed to branch master at GNU Mailman / Mailman Core


Commits:
ee8dfef5 by legoktm at 2021-05-11T05:25:59+00:00
Optimize MembershipManager.memberships_pending_warning()

- - - - -
3d8ac312 by Abhilash Raj at 2021-05-11T05:26:00+00:00
Merge branch 'faster-query' into 'master'

Optimize MembershipManager.memberships_pending_warning()

See merge request mailman/mailman!857
- - - - -


2 changed files:

- src/mailman/docs/NEWS.rst
- src/mailman/model/member.py


Changes:

=====================================
src/mailman/docs/NEWS.rst
=====================================
@@ -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
 ------------


=====================================
src/mailman/model/member.py
=====================================
@@ -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



View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/b04532646e55eabba92fa7ca87c07e9e350013cb...3d8ac31202d466843c0b5a3cf794d7322a822f3c

-- 
View it on GitLab: 
https://gitlab.com/mailman/mailman/-/compare/b04532646e55eabba92fa7ca87c07e9e350013cb...3d8ac31202d466843c0b5a3cf794d7322a822f3c
You're receiving this email because of your account on gitlab.com.


_______________________________________________
Mailman-checkins mailing list -- mailman-checkins@python.org
To unsubscribe send an email to mailman-checkins-le...@python.org
https://mail.python.org/mailman3/lists/mailman-checkins.python.org/
Member address: arch...@jab.org

Reply via email to