~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to cronscripts/send-bug-notifications.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-08-17 19:51:38 UTC
  • mfrom: (13627.2.15 bug-813322-2)
  • Revision ID: launchpad@pqm.canonical.com-20110817195138-yox3nrvqtq27gpb5
[r=stevenk][bug=813322] Defer duplicate bug recipient list
        calculation until processing by the cron job.

Show diffs side-by-side

added added

removed removed

Lines of Context:
22
22
from lp.services.mail.sendmail import sendmail
23
23
from lp.bugs.enum import BugNotificationStatus
24
24
from lp.bugs.interfaces.bugnotification import IBugNotificationSet
25
 
from lp.bugs.scripts.bugnotification import get_email_notifications
 
25
from lp.bugs.scripts.bugnotification import (
 
26
    get_email_notifications,
 
27
    process_deferred_notifications,
 
28
    )
26
29
from lp.services.scripts.base import LaunchpadCronScript
27
30
 
28
31
 
29
32
class SendBugNotifications(LaunchpadCronScript):
30
33
    def main(self):
31
34
        notifications_sent = False
32
 
        pending_notifications = get_email_notifications(getUtility(
33
 
            IBugNotificationSet).getNotificationsToSend())
 
35
        bug_notification_set = getUtility(IBugNotificationSet)
 
36
        deferred_notifications = \
 
37
            bug_notification_set.getDeferredNotifications()
 
38
        process_deferred_notifications(deferred_notifications)
 
39
        pending_notifications = get_email_notifications(
 
40
            bug_notification_set.getNotificationsToSend())
34
41
        for (bug_notifications,
35
42
             omitted_notifications,
36
43
             messages) in pending_notifications:
59
66
    script = SendBugNotifications('send-bug-notifications',
60
67
        dbuser=config.malone.bugnotification_dbuser)
61
68
    script.lock_and_run()
62