~launchpad-pqm/launchpad/devel

« back to all changes in this revision

Viewing changes to lib/lp/registry/model/person.py

  • Committer: Stuart Bishop
  • Date: 2011-05-02 05:53:52 UTC
  • mfrom: (7675.1121.1 pending-db-changes)
  • mto: This revision was merged to the branch mainline in revision 13013.
  • Revision ID: stuart.bishop@canonical.com-20110502055352-cilw2zfwiki7xsvd
Merged pending-db-changes into db-deploy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
3556
3556
            WHERE bug_supervisor=%(from_id)d
3557
3557
            ''' % vars())
3558
3558
 
 
3559
    def _mergeStructuralSubscriptions(self, cur, from_id, to_id):
 
3560
        # Update StructuralSubscription entries that will not conflict.
 
3561
        # We separate this out from the parent query primarily to help
 
3562
        # keep within our line length constraints, though it might make
 
3563
        # things more readable otherwise as well.
 
3564
        exists_query = '''
 
3565
            SELECT StructuralSubscription.id
 
3566
            FROM StructuralSubscription
 
3567
            WHERE StructuralSubscription.subscriber=%(to_id)d AND (
 
3568
                StructuralSubscription.product=SSub.product
 
3569
                OR 
 
3570
                StructuralSubscription.project=SSub.project
 
3571
                OR 
 
3572
                StructuralSubscription.distroseries=SSub.distroseries
 
3573
                OR 
 
3574
                StructuralSubscription.milestone=SSub.milestone
 
3575
                OR 
 
3576
                StructuralSubscription.productseries=SSub.productseries
 
3577
                OR 
 
3578
                (StructuralSubscription.distribution=SSub.distribution
 
3579
                 AND StructuralSubscription.sourcepackagename IS NULL
 
3580
                 AND SSub.sourcepackagename IS NULL)
 
3581
                OR
 
3582
                (StructuralSubscription.sourcepackagename=
 
3583
                    SSub.sourcepackagename
 
3584
                 AND StructuralSubscription.sourcepackagename=
 
3585
                    SSub.sourcepackagename)
 
3586
                )
 
3587
            '''
 
3588
        cur.execute(('''
 
3589
            UPDATE StructuralSubscription
 
3590
            SET subscriber=%(to_id)d
 
3591
            WHERE subscriber=%(from_id)d AND id NOT IN (
 
3592
                SELECT SSub.id
 
3593
                FROM StructuralSubscription AS SSub
 
3594
                WHERE 
 
3595
                    SSub.subscriber=%(from_id)d
 
3596
                    AND EXISTS (''' + exists_query + ''')
 
3597
            )
 
3598
            ''') % vars())
 
3599
        # Delete the rest.  We have to explicitly delete the bug subscription
 
3600
        # filters first because there is not a cascade delete set up in the
 
3601
        # db.
 
3602
        cur.execute('''
 
3603
            DELETE FROM BugSubscriptionFilter
 
3604
            WHERE structuralsubscription IN (
 
3605
                SELECT id
 
3606
                FROM StructuralSubscription
 
3607
                WHERE subscriber=%(from_id)d)
 
3608
            ''' % vars())
 
3609
        cur.execute('''
 
3610
            DELETE FROM StructuralSubscription WHERE subscriber=%(from_id)d
 
3611
            ''' % vars())
 
3612
 
3559
3613
    def _mergeSpecificationFeedback(self, cur, from_id, to_id):
3560
3614
        # Update the SpecificationFeedback entries that will not conflict
3561
3615
        # and trash the rest.
3982
4036
        self._mergePackageBugSupervisor(cur, from_id, to_id)
3983
4037
        skip.append(('packagebugsupervisor', 'bug_supervisor'))
3984
4038
 
 
4039
        self._mergeStructuralSubscriptions(cur, from_id, to_id)
 
4040
        skip.append(('structuralsubscription', 'subscriber'))
 
4041
 
3985
4042
        self._mergeSpecificationFeedback(cur, from_id, to_id)
3986
4043
        skip.append(('specificationfeedback', 'reviewer'))
3987
4044
        skip.append(('specificationfeedback', 'requester'))