~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/bugs/model/bugnotification.py

  • Committer: Launchpad Patch Queue Manager
  • Date: 2011-05-23 18:43:31 UTC
  • mfrom: (13084.2.6 page-match-rewrite-url)
  • Revision ID: launchpad@pqm.canonical.com-20110523184331-dhd2c7cgfuu49epw
[r=sinzui][bug=784273] Adds facility to the PageMatch to handle bad
        URIs

Show diffs side-by-side

added added

removed removed

Lines of Context:
144
144
        # Now we do some calls that are purely for cacheing.
145
145
        # Converting these into lists forces the queries to execute.
146
146
        if pending_notifications:
147
 
            list(
 
147
            cached_people = list(
148
148
                getUtility(IPersonSet).getPrecachedPersonsFromIDs(
149
149
                    list(people_ids),
150
150
                    need_validity=True,
151
151
                    need_preferred_email=True))
152
 
            list(
 
152
            cached_bugs = list(
153
153
                IStore(Bug).find(Bug, In(Bug.id, list(bug_ids))))
154
154
        pending_notifications.reverse()
155
155
        return pending_notifications
189
189
 
190
190
        return bug_notification
191
191
 
192
 
    def getRecipientFilterData(self, bug, recipient_to_sources,
193
 
                               notifications):
 
192
    def getRecipientFilterData(self, recipient_to_sources, notifications):
194
193
        """See `IBugNotificationSet`."""
195
194
        if not notifications or not recipient_to_sources:
196
195
            # This is a shortcut that will remove some error conditions.
197
196
            return {}
198
 
        # Collect bug mute information.
199
 
        from lp.bugs.model.bug import BugMute
200
 
        store = IStore(BugMute)
201
 
        muted_person_ids = set(list(
202
 
            store.find(BugMute.person_id,
203
 
                       BugMute.bug == bug)))
204
197
        # This makes two calls to the database to get all the
205
198
        # information we need. The first call gets the filter ids and
206
199
        # descriptions for each recipient, and then we divide up the
209
202
        source_person_id_map = {}
210
203
        recipient_id_map = {}
211
204
        for recipient, sources in recipient_to_sources.items():
212
 
            if recipient.id in muted_person_ids:
213
 
                continue
214
205
            source_person_ids = set()
215
206
            recipient_id_map[recipient.id] = {
216
207
                'principal': recipient,
240
231
            Join(StructuralSubscription,
241
232
                 BugSubscriptionFilter.structural_subscription_id ==
242
233
                    StructuralSubscription.id))
243
 
        if len(source_person_id_map) == 0:
244
 
            filter_data = []
245
 
        else:
246
 
            filter_data = source.find(
247
 
                (StructuralSubscription.subscriberID,
248
 
                 BugSubscriptionFilter.id,
249
 
                 BugSubscriptionFilter.description),
250
 
                In(BugNotificationFilter.bug_notification_id,
251
 
                   [notification.id for notification in notifications]),
252
 
                In(StructuralSubscription.subscriberID,
253
 
                   source_person_id_map.keys()))
 
234
        filter_data = source.find(
 
235
            (StructuralSubscription.subscriberID,
 
236
             BugSubscriptionFilter.id,
 
237
             BugSubscriptionFilter.description),
 
238
            In(BugNotificationFilter.bug_notification_id,
 
239
               [notification.id for notification in notifications]),
 
240
            In(StructuralSubscription.subscriberID,
 
241
               source_person_id_map.keys()))
254
242
        filter_ids = []
255
243
        # Record the filters for each source.
256
244
        for source_person_id, filter_id, filter_description in filter_data:
271
259
            mute_data = store.find(
272
260
                (BugSubscriptionFilterMute.person_id,
273
261
                 BugSubscriptionFilterMute.filter_id),
274
 
                In(BugSubscriptionFilterMute.person_id,
275
 
                   recipient_id_map.keys()),
 
262
                In(BugSubscriptionFilterMute.person_id, recipient_id_map.keys()),
276
263
                In(BugSubscriptionFilterMute.filter_id, filter_ids))
277
264
            for person_id, filter_id in mute_data:
278
265
                if filter_id in recipient_id_map[person_id]['filters']: