Merge lp://staging/~wallyworld/launchpad/improve-personpicker-bugtaskaffiliation-798764 into lp://staging/launchpad

Proposed by Ian Booth
Status: Merged
Approved by: Curtis Hovey
Approved revision: 13598
Merge reported by: Curtis Hovey
Merged at revision: not available
Proposed branch: lp://staging/~wallyworld/launchpad/improve-personpicker-bugtaskaffiliation-798764
Merge into: lp://staging/launchpad
Diff against target: 219 lines (+117/-19)
3 files modified
lib/lp/registry/model/pillaraffiliation.py (+24/-2)
lib/lp/registry/tests/test_pillaraffiliation.py (+83/-12)
lib/lp/testing/factory.py (+10/-5)
To merge this branch: bzr merge lp://staging/~wallyworld/launchpad/improve-personpicker-bugtaskaffiliation-798764
Reviewer Review Type Date Requested Status
Curtis Hovey (community) code Approve
Review via email: mp+70255@code.staging.launchpad.net

Commit message

Improve the bugtask affiliation adaptor to account for pillar driver, security contact and bug supervisor.

Description of the change

Improve the bugtask affiliation adaptor to account for:
- pillar driver
- pillar security contact
- pillar bug supervisor

The bug mentions adding affiliation checks for blueprints etc - this will be done in another branch and another bug will be created for that.

== Implementation ==

Simply update the getAffiliationBadge() method.

There are always 4 queries executed to do the core work, being:
select from Bug
select from BugTask
select from Person
select from Product/Distribution

The query counts stay the same regardless of whether affiliation checks are done for supervisor, security contact etc. The bug report mentions performance concerns but since the checks for supervisor, security contact do not add to the query count, it's ok to do these checks.

== Tests ==

Update lp/registry/tests/test_pillaraffiliation.py
As well as functional tests, tests are included to check the query counts.

== Lint ==

Linting changed files:
  lib/lp/registry/model/pillaraffiliation.py
  lib/lp/registry/tests/test_pillaraffiliation.py
  lib/lp/testing/factory.py

To post a comment you must log in.
Revision history for this message
Curtis Hovey (sinzui) wrote :

> === modified file 'lib/lp/registry/model/pillaraffiliation.py'
> --- lib/lp/registry/model/pillaraffiliation.py 2011-08-03 06:34:41 +0000
> +++ lib/lp/registry/model/pillaraffiliation.py 2011-08-03 06:34:43 +0000
> @@ -72,7 +75,20 @@
>
> def getAffiliationBadge(self, person):
> pillar = self.context.pillar
> - affiliated = person.inTeam(pillar.owner)
> + bug_supervisor = None
> + security_contact = None
> + driver = None
> + if IHasAppointedDriver.providedBy(pillar):
> + driver = pillar.driver
> + if IHasSecurityContact.providedBy(pillar):
> + security_contact = pillar.security_contact
> + if IHasBugSupervisor.providedBy(pillar):
> + bug_supervisor = pillar.bug_supervisor
> +
> + affiliated = (person.inTeam(pillar.owner) or
> + person.inTeam(bug_supervisor) or
> + person.inTeam(security_contact) or
> + person.inTeam(driver))

Check driver before bug_supervisor. It is a often a larger group and more
important for all Lp applications. bug_supervisor and security_contact are
primarilly about private bugs and security bugs.

> === modified file 'lib/lp/registry/tests/test_pillaraffiliation.py'
> --- lib/lp/registry/tests/test_pillaraffiliation.py 2011-08-03 06:34:41 +0000
> +++ lib/lp/registry/tests/test_pillaraffiliation.py 2011-08-03 06:34:43 +0000
..
> +class TestBugTaskPillarAffiliation(TestCaseWithFactory):
>
> layer = DatabaseFunctionalLayer
>
> - def test_bugtask_distro_affiliation(self):
> + def _check_affiliated_with_distro(self, person, distro):
> + bugtask = self.factory.makeBugTask(target=distro)
> + badge = IHasAffiliation(bugtask).getAffiliationBadge(person)
> + self.assertEqual(
> + badge, ("/@@/distribution-badge", "Affiliated with Pting"))

Users wanted to know *how* the user was affilliated. Is the user the
maintainer or the bug_supervisor. This branch does not address this concern.
Were you planning to addess this in a future branch?

Maybe we could change the badge text to state the role?
getAffiliationBadge() could return the role of the successful test and that
is used to make the alt text that will also be shown in the expanded details.

        affilliated = None
        if person.inTeam(pillar.owner):
            affilliated = 'maintainer'
        elif person.inTeam(driver):
            affilliated = 'driver'
        elif person.inTeam(bug_supervisor):
            affilliated = 'bug supervisor'
        elif person.inTeam(security_contact):
            affilliated = 'security contact'

        if not affiliated:
            return None
        alt_text = "%s %s" % (pillar.displayname, affiliated)

So the picker would show that both of us as:
    Launchpad maintainer

review: Needs Information (code)
Revision history for this message
Ian Booth (wallyworld) wrote :

>
> Users wanted to know *how* the user was affilliated. Is the user the
> maintainer or the bug_supervisor. This branch does not address this concern.
> Were you planning to addess this in a future branch?
>
> Maybe we could change the badge text to state the role?
> getAffiliationBadge() could return the role of the successful test and that
> is used to make the alt text that will also be shown in the expanded details.
>
> affilliated = None
> if person.inTeam(pillar.owner):
> affilliated = 'maintainer'
> elif person.inTeam(driver):
> affilliated = 'driver'
> elif person.inTeam(bug_supervisor):
> affilliated = 'bug supervisor'
> elif person.inTeam(security_contact):
> affilliated = 'security contact'
>
> if not affiliated:
> return None
> alt_text = "%s %s" % (pillar.displayname, affiliated)
>
> So the picker would show that both of us as:
> Launchpad maintainer

Ah, I fail. Thanks for picking this up. I also like the suggested
implementation. I'll make the changes.

13597. By Ian Booth

Merge latest picker expander code

13598. By Ian Booth

Improve affiliatin text

Revision history for this message
Curtis Hovey (sinzui) wrote :

Thank you for the update.

review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
The diff is not available at this time. You can reload the page or download it.