Code review comment for lp:~kfogel/launchpad/505845-affects-me-too-from-dups

Revision history for this message
Karl Fogel (kfogel) wrote :

Make the DB change necessary to implement the solution described in https://bugs.edge.launchpad.net/malone/+bug/505845/comments/1 . Short version:

This new field will allow Launchpad to remember when a person is affected by a bug via duplication, versus directly; and will be able to represent perverse things like people claiming to be affected by a bug but not by its dup.

The basic plan is to add a new column:

  ALTER table bugaffectsperson ADD COLUMN master_affects integer;

By default, the new column has the same value as the 'bug' column. But when a bug D is marked as a dup of bug M, D's 'master_affects' is set to M (unless there was already a record indicating M does not affect P).

We'll do most queries on the 'master_affects' column (instead of on 'bug' as currently). For example, when a person P visits the page for bug M, we figure out whether to show it as affecting them based on whether there are any rows with M in 'master_affects'. And when we're calculating total affects-person counts for bug heat, we query on the master_affects column. Thus, if D is later unduplicated from M, the affects-person count on M will automatically be decremented properly.

See the above-linked comment for more details.

NOTE: There will need to be some code updates following this patch -- we know about them. Until then, you'll see test errors like 'IntegrityError: null value in column "master_affects" violates not-null constraint'.

OTHER NOTE: There is a possibility this solution will help with the performance issues we have with the subscriber portlet on the bugs pages; however, we're not positive enough to say that with 100% certainty yet. We just wanted to point it out for warm fuzzies.

« Back to merge proposal