Merge lp:~deryck/launchpad/has-bug-heat-interface-529846 into lp:launchpad
| Status: | Merged | ||||
|---|---|---|---|---|---|
| Approved by: | Guilherme Salgado on 2010-03-19 | ||||
| Approved revision: | no longer in the source branch. | ||||
| Merged at revision: | not available | ||||
| Proposed branch: | lp:~deryck/launchpad/has-bug-heat-interface-529846 | ||||
| Merge into: | lp:launchpad | ||||
| Diff against target: |
530 lines (+124/-97) 11 files modified
lib/lp/bugs/interfaces/bugtarget.py (+15/-10) lib/lp/bugs/model/bugtarget.py (+51/-46) lib/lp/registry/configure.zcml (+15/-3) lib/lp/registry/model/distribution.py (+7/-4) lib/lp/registry/model/distributionsourcepackage.py (+6/-3) lib/lp/registry/model/distroseries.py (+7/-5) lib/lp/registry/model/person.py (+0/-10) lib/lp/registry/model/product.py (+7/-4) lib/lp/registry/model/productseries.py (+6/-5) lib/lp/registry/model/project.py (+4/-3) lib/lp/registry/model/sourcepackage.py (+6/-4) |
||||
| To merge this branch: | bzr merge lp:~deryck/launchpad/has-bug-heat-interface-529846 | ||||
| Related bugs: |
|
| Reviewer | Review Type | Date Requested | Status |
|---|---|---|---|
| Guilherme Salgado (community) | 2010-03-19 | Approve on 2010-03-19 | |
|
Review via email:
|
|||
Commit Message
Imlement IHasBugHeat interface for targets which can have bug heat.
Description of the Change
This branch fixes bug 529846. It creates an IHasBugHeat interface and
makes use of this for bug targets that should have bug heat. It is not
used for IPerson, for example.
There is no functionality changed here; this just cleans up the code a bit.
To test:
./bin/test -cvvt test_bugheat
= Launchpad lint =
Checking for conflicts. and issues in doctests and templates.
Running jslint, xmllint, pyflakes, and pylint.
Using normal rules.
Linting changed files:
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/
lib/lp/

Looks good to me; just one minor nitpick below
review approve
status approved
On Fri, 2010-03-19 at 15:41 +0000, Deryck Hodge wrote: bugs/model/ bugtarget. py' bugs/model/ bugtarget. py 2010-03-09 15:13:40 +0000 bugs/model/ bugtarget. py 2010-03-19 15:41:50 +0000 TargetMixin' , s(all_tasks_ query) count() . all_bugtasks ResultSet instance, and this Set._result_ set.is_ empty() all_bugtasks) kContextClause( ), privacy_ filter( user) append( privacy_ filter) select_ columns) , ' AND '.join( conditions) ))
> === modified file 'lib/lp/
> --- lib/lp/
> +++ lib/lp/
> @@ -9,6 +9,7 @@
> __all__ = [
> 'BugTargetBase',
> 'HasBugsBase',
> + 'HasBugHeatMixin',
> 'OfficialBugTag',
> 'OfficialBugTag
> ]
> @@ -162,8 +163,57 @@
>
> return self.searchTask
>
> + @property
> + def has_bugtasks(self):
> + """See `IHasBugs`."""
> + # Check efficiently if any bugtasks exist. We should avoid
> + # expensive calls like all_bugtasks.
> + # returns a storm.SQLObject
> + # class does not provide methods like is_empty(). But we can
> + # indirectly call SQLObjectResult
> + # by converting all_bugtasks into a boolean object.
> + return bool(self.
> +
> + def getBugCounts(self, user, statuses=None):
> + """See `IHasBugs`."""
> + if statuses is None:
> + statuses = BugTaskStatus.items
> + statuses = list(statuses)
> +
> + count_column = """
> + COUNT (CASE WHEN BugTask.status = %s
> + THEN BugTask.id ELSE NULL END)"""
> + select_columns = [count_column % sqlvalues(status)
> + for status in statuses]
> + conditions = [
> + '(%s)' % self._getBugTas
> + 'BugTask.bug = Bug.id',
> + 'Bug.duplicateof is NULL']
> + privacy_filter = get_bug_
> + if privacy_filter:
> + conditions.
> +
> + cur = cursor()
> + cur.execute(
> + "SELECT %s FROM BugTask, Bug WHERE %s" % (
> + ', '.join(
> + counts = cur.fetchone()
> + return dict(zip(statuses, counts))
> +
> +
> +
One blank line too much here.
> +class BugTargetBase( HasBugsBase) :
> + """Standard functionality for IBugTargets.
> +
> + All IBugTargets should inherit from this class.
> + """
> +
> +
--
Guilherme Salgado <email address hidden>