Merge lp:~deryck/launchpad/hot-bugtasks-to-hot-bugs-442170 into lp:launchpad/db-devel

Proposed by Deryck Hodge
Status: Merged
Approved by: Eleanor Berger
Approved revision: no longer in the source branch.
Merged at revision: not available
Proposed branch: lp:~deryck/launchpad/hot-bugtasks-to-hot-bugs-442170
Merge into: lp:launchpad/db-devel
Diff against target: 186 lines (+72/-30)
4 files modified
lib/lp/bugs/browser/bugtarget.py (+21/-0)
lib/lp/bugs/browser/bugtask.py (+0/-9)
lib/lp/bugs/stories/bugs/xx-product-bugs-page.txt (+48/-18)
lib/lp/bugs/templates/bugtarget-bugs.pt (+3/-3)
To merge this branch: bzr merge lp:~deryck/launchpad/hot-bugtasks-to-hot-bugs-442170
Reviewer Review Type Date Requested Status
Eleanor Berger (community) Approve
Review via email: mp+17826@code.launchpad.net

Commit message

Make the method getting a hot bugs list get bugs by heat rather than recently touched bugtasks.

To post a comment you must log in.
Revision history for this message
Deryck Hodge (deryck) wrote :

This branch moves the hot_bugtasks method from the bug listing view to a hot_bugs method on a bug target view, which changes the behavior to return 10 bugs according to heat rather than recently touched bug tasks.

This change also allows us to fix Bug #442170, since the code ensures the same bug isn't shown twice. The code uses default_bugtask for display.

The "hot bugs" test in stories/bugs/xx-product-bugs-page.txt has been updated to use factory data, rather than sample data, and to test that bugs are listed by heat.

The branch builds on a branch from Tom/Brian M. that allows sorting by heat, so the diff for my changes is pasted:

http://pastebin.ubuntu.com/360139/

Revision history for this message
Eleanor Berger (intellectronica) wrote :

At last, real hot bugs!!!

We've discussed a few minor changes:

1. Exiting from the loop instead of returning twice in hot_bugs.
2. Accessing bug/prop instead of bug/default_bugtask/bug/prop in the template.

Everything else looks great.

review: Approve
Revision history for this message
Eleanor Berger (intellectronica) wrote :

On further discussion, we realised that there's a subtle problem with using the default_bugtask, since it isn't necessarily a task on the same bugtarget we're viewing. Instead of returning bugs, we should return the task we got back from searchTasks. That does complicate the loop in hot_bugs a bit.

review: Needs Fixing
Revision history for this message
Deryck Hodge (deryck) wrote :
Download full text (3.9 KiB)

I believe I've fixed everything now. Latest incremental diff:

=== modified file 'lib/lp/bugs/browser/bugtarget.py'
--- lib/lp/bugs/browser/bugtarget.py 2010-01-20 18:27:12 +0000
+++ lib/lp/bugs/browser/bugtarget.py 2010-01-21 17:51:36 +0000
@@ -1264,12 +1264,13 @@
         hot_bugs = []
         count = 0
         for task in bugtasks:
- if task.bug not in hot_bugs:
+ # Ensure we only represent a bug once in the list.
+ if task.bug not in [hot_task.bug for hot_task in hot_bugs]:
                 if count < 10:
- hot_bugs.append(task.bug)
+ hot_bugs.append(task)
                     count += 1
- elif count == 10:
- return hot_bugs
+ else:
+ break
         return hot_bugs

=== modified file 'lib/lp/bugs/model/bugtask.py'
--- lib/lp/bugs/model/bugtask.py 2010-01-19 22:34:00 +0000
+++ lib/lp/bugs/model/bugtask.py 2010-01-21 20:45:05 +0000
@@ -1257,7 +1257,7 @@
         "number_of_duplicates": "Bug.number_of_duplicates",
         "message_count": "Bug.message_count",
         "users_affected_count": "Bug.users_affected_count",
- "heat": "Bug.hotness",
+ "heat": "Bug.heat",
         }

     _open_resolved_upstream = """

=== modified file 'lib/lp/bugs/stories/bugs/xx-product-bugs-page.txt'
--- lib/lp/bugs/stories/bugs/xx-product-bugs-page.txt 2010-01-20 20:52:20 +0000
+++ lib/lp/bugs/stories/bugs/xx-product-bugs-page.txt 2010-01-21 17:56:06 +0000
@@ -203,8 +203,8 @@
     #21 Summary for new bug 6 New Undecided ...

-Fix released bugs are not shown. We demonstrate this by setting the bugtask
-for bug 18 to be "Fix released".
+Fix Released bugs are not shown. We demonstrate this by setting the bugtask
+for bug 18 to be "Fix Released".

     >>> from lp.bugs.interfaces.bug import BugTaskStatus, IBugSet
     >>> from lp.registry.interfaces.person import IPersonSet
@@ -215,7 +215,7 @@
     ... BugTaskStatus.FIXRELEASED, project_owner)
     >>> logout()

-And then reloading the page. The Fix released bug, bug 18, is no longer shown.
+And then reloading the page. The Fix Released bug, bug 18, is no longer shown.

     >>> anon_browser.reload()
     >>> print extract_text(

=== modified file 'lib/lp/bugs/templates/bugtarget-bugs.pt'
--- lib/lp/bugs/templates/bugtarget-bugs.pt 2010-01-20 18:16:50 +0000
+++ lib/lp/bugs/templates/bugtarget-bugs.pt 2010-01-21 17:33:54 +0000
@@ -113,23 +113,23 @@
           </tr>
         </thead>
         <tbody>
- <tr tal:repeat="bug view/hot_bugs">
+ <tr tal:repeat="bugtask view/hot_bugs">
             <td class="icon left">
               <img alt="" src="/@@/bug" />
             </td>
             <td style="text-align: right">
- #<span tal:replace="bug/default_bugtask/bug/id" />
+ #<span tal:replace="bugtask/bug/id" />
             </td>
             <td>
- <a tal:attributes="href bug/default_bugtask/fmt:url"
- tal:content="bug/default_bugtask/bug/title" />
+ <a tal:attributes="href bugtask/fmt:url"
+ tal:content="bugtask/bug/title" />
      ...

Read more...

Revision history for this message
Eleanor Berger (intellectronica) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'lib/lp/bugs/browser/bugtarget.py'
--- lib/lp/bugs/browser/bugtarget.py 2010-01-07 05:41:58 +0000
+++ lib/lp/bugs/browser/bugtarget.py 2010-01-22 16:41:25 +0000
@@ -40,6 +40,7 @@
40from canonical.config import config40from canonical.config import config
41from lp.bugs.browser.bugtask import BugTaskSearchListingView41from lp.bugs.browser.bugtask import BugTaskSearchListingView
42from lp.bugs.interfaces.bug import IBug42from lp.bugs.interfaces.bug import IBug
43from lp.bugs.interfaces.bugtask import BugTaskSearchParams
43from canonical.launchpad.browser.feeds import (44from canonical.launchpad.browser.feeds import (
44 BugFeedLink, BugTargetLatestBugsFeedLink, FeedsMixin,45 BugFeedLink, BugTargetLatestBugsFeedLink, FeedsMixin,
45 PersonLatestBugsFeedLink)46 PersonLatestBugsFeedLink)
@@ -55,6 +56,7 @@
55from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities56from canonical.launchpad.interfaces.launchpad import ILaunchpadCelebrities
56from canonical.launchpad.interfaces.temporaryblobstorage import (57from canonical.launchpad.interfaces.temporaryblobstorage import (
57 ITemporaryStorageManager)58 ITemporaryStorageManager)
59from canonical.launchpad.searchbuilder import any
58from canonical.launchpad.webapp import urlappend60from canonical.launchpad.webapp import urlappend
59from canonical.launchpad.webapp.breadcrumb import Breadcrumb61from canonical.launchpad.webapp.breadcrumb import Breadcrumb
60from canonical.launchpad.webapp.interfaces import ILaunchBag, NotFoundError62from canonical.launchpad.webapp.interfaces import ILaunchBag, NotFoundError
@@ -1252,6 +1254,25 @@
1252 else:1254 else:
1253 return 'None specified'1255 return 'None specified'
12541256
1257 @property
1258 def hot_bugs(self):
1259 """Return the 10 hotest bugs according to IBug.heat."""
1260 params = BugTaskSearchParams(
1261 orderby=['-heat', '-date_last_updated'], omit_dupes=True,
1262 user=self.user, status=any(*UNRESOLVED_BUGTASK_STATUSES))
1263 bugtasks = self.context.searchTasks(params)
1264 hot_bugs = []
1265 count = 0
1266 for task in bugtasks:
1267 # Ensure we only represent a bug once in the list.
1268 if task.bug not in [hot_task.bug for hot_task in hot_bugs]:
1269 if count < 10:
1270 hot_bugs.append(task)
1271 count += 1
1272 else:
1273 break
1274 return hot_bugs
1275
12551276
1256class BugTargetBugTagsView(LaunchpadView):1277class BugTargetBugTagsView(LaunchpadView):
1257 """Helper methods for rendering the bug tags portlet."""1278 """Helper methods for rendering the bug tags portlet."""
12581279
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py 2010-01-19 16:43:20 +0000
+++ lib/lp/bugs/browser/bugtask.py 2010-01-22 16:41:25 +0000
@@ -2726,15 +2726,6 @@
2726 return IDistributionSourcePackage(self.context, None)2726 return IDistributionSourcePackage(self.context, None)
27272727
2728 @property2728 @property
2729 def hot_bugtasks(self):
2730 """Return the 10 most recently updated bugtasks for this target."""
2731 params = BugTaskSearchParams(
2732 orderby="-date_last_updated", omit_dupes=True, user=self.user,
2733 status=any(*UNRESOLVED_BUGTASK_STATUSES))
2734 search = self.context.searchTasks(params)
2735 return list(search[:10])
2736
2737 @property
2738 def addquestion_url(self):2729 def addquestion_url(self):
2739 """Return the URL for the +addquestion view for the context."""2730 """Return the URL for the +addquestion view for the context."""
2740 if IQuestionTarget.providedBy(self.context):2731 if IQuestionTarget.providedBy(self.context):
27412732
=== modified file 'lib/lp/bugs/stories/bugs/xx-product-bugs-page.txt'
--- lib/lp/bugs/stories/bugs/xx-product-bugs-page.txt 2010-01-18 18:27:32 +0000
+++ lib/lp/bugs/stories/bugs/xx-product-bugs-page.txt 2010-01-22 16:41:25 +0000
@@ -131,38 +131,68 @@
131131
132== Hot Bugs ==132== Hot Bugs ==
133133
134A listing of the 10 'hottest' bugs (currently simply the bugs most134A listing of the 10 'hottest' bugs is displayed to allow a quick
135recently touched) is displayed to allow a quick overview of the project.135overview of the project.
136
137To demonstrate this, we create 10 bugs and adjust their heat values manually.
138
139 >>> from zope.component import getUtility
140 >>> from canonical.launchpad.ftests import login, logout
141 >>> from lp.registry.interfaces.product import IProductSet
142 >>> import transaction
143 >>> login('foo.bar@canonical.com')
144 >>> firefox = getUtility(IProductSet).getByName("firefox")
145 >>> heat_values = [0, 400, 200, 600, 100, 50, 50, 50, 50, 50, 50, 50]
146 >>> for count in range(1, 11):
147 ... summary = 'Summary for new bug %d' % count
148 ... bug = factory.makeBug(title=summary, product=firefox)
149 ... bug.setHeat(heat_values[count])
150 >>> transaction.commit()
151 >>> logout()
152
136For each bug we have the number, title, status, importance and the time153For each bug we have the number, title, status, importance and the time
137since the last update.154since the last update.
138155
139 >>> anon_browser.open('http://bugs.launchpad.dev/firefox')156 >>> anon_browser.open('http://bugs.launchpad.dev/firefox')
140 >>> print extract_text(157 >>> print extract_text(
141 ... find_tag_by_id(anon_browser.contents, 'hot-bugs'))158 ... find_tag_by_id(anon_browser.contents, 'hot-bugs'))
142 Summary Status Importance Last changed159 Summary Status Importance Last changed
143 #5 Firefox install... New Critical on 2006-07-14160 #18 Summary for new bug 3 New Undecided ...
144 #4 Reflow problems... New Medium on 2006-07-14161 #16 Summary for new bug 1 New Undecided ...
145 #1 Firefox does no... New Low on 2006-05-19162 #17 Summary for new bug 2 New Undecided ...
146163 #19 Summary for new bug 4 New Undecided ...
147164 #25 Summary for new bug 10 New Undecided ...
148Fix released bugs are not shown. We demonstrate this by setting the bugtask165 #22 Summary for new bug 7 New Undecided ...
149for bug 4 to be "Fix released".166 #23 Summary for new bug 8 New Undecided ...
150167 #24 Summary for new bug 9 New Undecided ...
151 >>> from zope.component import getUtility168 #20 Summary for new bug 5 New Undecided ...
169 #21 Summary for new bug 6 New Undecided ...
170
171
172Fix Released bugs are not shown. We demonstrate this by setting the bugtask
173for bug 18 to be "Fix Released".
174
152 >>> from lp.bugs.interfaces.bug import BugTaskStatus, IBugSet175 >>> from lp.bugs.interfaces.bug import BugTaskStatus, IBugSet
153 >>> from lp.registry.interfaces.person import IPersonSet176 >>> from lp.registry.interfaces.person import IPersonSet
154 >>> login('foo.bar@canonical.com')177 >>> login('foo.bar@canonical.com')
155 >>> bug_4 = getUtility(IBugSet).get(4)178 >>> bug_18 = getUtility(IBugSet).get(18)
156 >>> project_owner = getUtility(IPersonSet).getByName('name12')179 >>> project_owner = getUtility(IPersonSet).getByName('name12')
157 >>> bug_4.bugtasks[0].transitionToStatus(180 >>> bug_18.bugtasks[0].transitionToStatus(
158 ... BugTaskStatus.FIXRELEASED, project_owner)181 ... BugTaskStatus.FIXRELEASED, project_owner)
159 >>> logout()182 >>> logout()
160183
161And then reloading the page. The Fix released bug, bug 4, is no longer shown.184And then reloading the page. The Fix Released bug, bug 18, is no longer shown.
162185
163 >>> anon_browser.reload()186 >>> anon_browser.reload()
164 >>> print extract_text(187 >>> print extract_text(
165 ... find_tag_by_id(anon_browser.contents, 'hot-bugs'))188 ... find_tag_by_id(anon_browser.contents, 'hot-bugs'))
166 Summary Status Importance Last changed189 Summary Status Importance Last changed
167 #5 Firefox install... New Critical on 2006-07-14190 #16 Summary for new bug 1 New Undecided ...
168 #1 Firefox does no... New Low on 2006-05-19191 #17 Summary for new bug 2 New Undecided ...
192 #19 Summary for new bug 4 New Undecided ...
193 #25 Summary for new bug 10 New Undecided ...
194 #22 Summary for new bug 7 New Undecided ...
195 #23 Summary for new bug 8 New Undecided ...
196 #24 Summary for new bug 9 New Undecided ...
197 #20 Summary for new bug 5 New Undecided ...
198 #21 Summary for new bug 6 New Undecided ...
169199
=== modified file 'lib/lp/bugs/templates/bugtarget-bugs.pt'
--- lib/lp/bugs/templates/bugtarget-bugs.pt 2010-01-20 17:26:54 +0000
+++ lib/lp/bugs/templates/bugtarget-bugs.pt 2010-01-22 16:41:25 +0000
@@ -95,7 +95,7 @@
95 </ul>95 </ul>
96 </div>96 </div>
9797
98 <tal:has_hot_bugs condition="view/hot_bugtasks">98 <tal:has_hot_bugs condition="view/hot_bugs">
99 <div class="search-box">99 <div class="search-box">
100 <metal:search100 <metal:search
101 use-macro="context/@@+bugtarget-macros-search/simple-search-form"101 use-macro="context/@@+bugtarget-macros-search/simple-search-form"
@@ -123,7 +123,7 @@
123 </tr>123 </tr>
124 </thead>124 </thead>
125 <tbody>125 <tbody>
126 <tr tal:repeat="bugtask view/hot_bugtasks">126 <tr tal:repeat="bugtask view/hot_bugs">
127 <td class="icon left">127 <td class="icon left">
128 <span tal:replace="structure bugtask/image:icon" />128 <span tal:replace="structure bugtask/image:icon" />
129 </td>129 </td>
@@ -148,7 +148,7 @@
148 </table>148 </table>
149 </tal:has_hot_bugs>149 </tal:has_hot_bugs>
150150
151 <tal:no_hot_bugs condition="not: view/hot_bugtasks">151 <tal:no_hot_bugs condition="not: view/hot_bugs">
152 <p id="no-bugs-filed"><strong>There are currently no bugs filed against152 <p id="no-bugs-filed"><strong>There are currently no bugs filed against
153 <tal:project_title replace="context/title" />.</strong></p>153 <tal:project_title replace="context/title" />.</strong></p>
154154

Subscribers

People subscribed via source and target branches

to status/vote changes: