Merge lp:~adeuring/launchpad/bug-528788-no-searchbox-without-hot-bugs into lp:launchpad
Status: | Merged |
---|---|
Approved by: | Gavin Panella |
Approved revision: | no longer in the source branch. |
Merged at revision: | not available |
Proposed branch: | lp:~adeuring/launchpad/bug-528788-no-searchbox-without-hot-bugs |
Merge into: | lp:launchpad |
Diff against target: |
187 lines (+102/-4) 6 files modified
lib/lp/bugs/doc/hasbugs.txt (+26/-0) lib/lp/bugs/interfaces/bugtarget.py (+2/-0) lib/lp/bugs/model/bugtarget.py (+10/-0) lib/lp/bugs/stories/bugs/xx-front-page-info.txt (+56/-0) lib/lp/bugs/templates/bugtarget-bugs.pt (+7/-4) lib/lp/registry/configure.zcml (+1/-0) |
To merge this branch: | bzr merge lp:~adeuring/launchpad/bug-528788-no-searchbox-without-hot-bugs |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Gavin Panella (community) | code | Approve | |
Abel Deuring (community) | Needs Resubmitting | ||
Eleanor Berger (community) | code | Approve | |
Review via email: mp+20657@code.launchpad.net |
Description of the change
This branch fixes bug 528788: "bug search field disappears when all bugs marked as Fixed/Invalid/
The fix is straightforward: The search box is only shown when at least one "hot" bug exists, but it should be shown if at least one bug exists, be it hot or not hot.
This requires a separate DB query: "Does at least one bug exist"? While IHasBugs objects have a property all_bugtasks, I did not want to use it: The SQL queries for similar properties like open_bugtasks, new_bugtasks etc need quite long to execute -- long enough that the content of the portlet showing the number of open bugs, new bugs etc is retrieved in a separate HTTP request.
Instead I defined a new property IHbasBugs.
mthaddon kindly ran an EXPLAIN ANALZYE of this query for Ubuntu: I t needs less than 1 millisecond. So, fast enough to not cause any timeout trouble, I think.
tests:
./bin/test -t hasbugs.txt
./bin/test -t xx-front-
= 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/
== Pylint notices ==
lib/lp/
60: [C0301] Line too long (79/78)
29: [F0401] Unable to import 'lazr.enum' (No module named enum)
30: [F0401] Unable to import 'lazr.restful.
31: [F0401] Unable to import 'lazr.restful.
32: [F0401] Unable to import 'lazr.restful.
66: [C0322, IHasBugs.
value_
^
required=
search_
status=
importance=
assignee=
bug_
bug_
bug_
bug_
owner=
affected_
has_
has_
tags=
tags_
omit_
omit_
status_
milestone_
IBugTaskSea
milestone=
component=
nominated_
has_
hardware_
title=u'The bus of a hardware device related to a bug',
vocabulary=
hardware_
title=(
u"The vendor ID of a hardware device related to a bug."),
description=(
u"Allowed values of the vendor ID depend on the bus of the "
"device.nn"
"Vendor IDs of PCI, PCCard and USB devices are hexadecimal "
"string representations of 16 bit integers in the format "
"'0x01ab': The prefix '0x', followed by exactly 4 digits; "
"where a digit is one of the characters 0..9, a..f. The "
"characters A..F are not allowed.nn"
"SCSI vendor IDs are strings with exactly 8 characters. "
"Shorter names are right-padded with space (0x20) characters."
"nn"
"IDs for other buses may be arbitrary strings."),
required=
hardware_
title=(
u"The product ID of a hardware device related to a bug."),
description=(
u"Allowed values of the product ID depend on the bus of the "
"device.nn"
"Product IDs of PCI, PCCard and USB devices are hexadecimal "
"string representations of 16 bit integers in the format "
"'0x01ab': The prefix '0x', followed by exactly 4 digits; "
"where a digit is one of the characters 0..9, a..f. The "
"characters A..F are not allowed.nn"
"SCSI product IDs are strings with exactly 16 characters. "
"Shorter names are right-padded with space (0x20) characters."
"nn"
"IDs for other buses may be arbitrary strings."),
required=
hardware_
title=(
u"The driver controlling a hardware device related to a "
"bug."),
required=
hardware_
title=(
u"The package of the driver which controls a hardware "
"device related to a bug."),
required=
hardware_
title=(
u"Search for bugs reported by people who own the given "
"device or who use the given hardware driver."),
required=
hardware_
title=(
u"Search for bugs where people affected by a bug own the "
"given device or use the given hardware driver."),
required=
hardware_
title=(
u"Search for bugs where a bug subscriber owns the "
"given device or uses the given hardware driver."),
required=
hardware_
title=(
u"Search for bugs which are linked to hardware reports "
"wich contain the given device or whcih contain a device"
"contolled by the given driver."),
required=
@operation_
@export_
def searchTasks(
order_by=None, search_text=None,
status=None, importance=None,
assignee=None, bug_reporter=None, bug_supervisor=
bug_
affected_
distributio
tags_
omit_
status_
milestone=None, component=None, nominated_for=None,
sourcepacka
hardware_
hardware_
hardware_
hardware_
hardware_
hardware_
hardware_
Accessing has_bugtasks failed for IPerson objects in self.all_ bugtasks. limit(1) because limit() is not defined in ISQLObjectResul tSet. Salgado suggested to cast instead all_bugtasks into a boolean object.
tests:
./bin/test -t hasbugs.txt (the "real" test of HasBugsBase. all_bugtasks)
./bin/test -t doc/person.txt (the previously failing test)
no lint
Incremental diff:
=== modified file 'lib/lp/ bugs/model/ bugtarget. py' bugs/model/ bugtarget. py 2010-03-08 09:38:21 +0000 bugs/model/ bugtarget. py 2010-03-09 14:29:31 +0000 bugtasks. count() > 0. ResultSet instance, and this class does not count() . all_bugtasks ResultSet instance, and this Set._result_ set.is_ empty() all_bugtasks)
--- lib/lp/
+++ lib/lp/
@@ -242,17 +242,13 @@
@property
def has_bugtasks(self):
"""See `IHasBugs`."""
- # Basically, the return value is self.all_
- # But finding, sorting and counting all bug tasks can take
- # a longer time (long enough that the HTML data for "number of
- # open, critical etc bugs" on a bug page is retrieved in a
- # separate request). all_bugtasks returns a
- # storm.SQLObject
- # provide methods like is_empty(), so limit the query
- # manually and simply check if at least one bug task exists.
- all_tasks = self.all_bugtasks
- all_tasks = all_tasks.limit(1)
- return all_tasks.count() > 0
+ # 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`."""