Merge lp:~adeuring/launchpad/bug-528374 into lp:launchpad/db-devel

Proposed by Abel Deuring
Status: Merged
Approved by: Graham Binns
Approved revision: not available
Merged at revision: not available
Proposed branch: lp:~adeuring/launchpad/bug-528374
Merge into: lp:launchpad/db-devel
Diff against target: 58 lines (+19/-4)
2 files modified
lib/lp/bugs/browser/bugtask.py (+7/-3)
lib/lp/bugs/browser/tests/bug-heat-view.txt (+12/-1)
To merge this branch: bzr merge lp:~adeuring/launchpad/bug-528374
Reviewer Review Type Date Requested Status
Graham Binns (community) code Approve
Review via email: mp+20232@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Abel Deuring (adeuring) wrote :

This branch fixes bug 528374: Flames misplaced on bug report page

It was caused by the removal of a <span> that enclosed the <img> tags of heat icons. I have not enough CSS-fu to explain why this <span> necessary...

As a drive-by fix, I ensured that a case like "7 out of 4 heat flames" (as can be currently seen on https://bugs.edge.launchpad.net/ubuntu/+bugs?orderby=-heat can no longer occur and that a max_heat value of 1 does not cause a divide-by-zero error.

test: ./bin/test -t bug-heat-view.txt

To check the position of haet icon: Open https://bugs.launchpad.dev/firefox/+bug/1 ; the icons should appear right of "Bug #1 reported by Sample Person on 2004-01-01"

no lint

Revision history for this message
Graham Binns (gmb) :
review: Approve (code)

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/lp/bugs/browser/bugtask.py'
2--- lib/lp/bugs/browser/bugtask.py 2010-02-27 20:20:03 +0000
3+++ lib/lp/bugs/browser/bugtask.py 2010-02-28 10:04:17 +0000
4@@ -1092,10 +1092,13 @@
5 max_bug_heat = float(max_bug_heat)
6 if heat / max_bug_heat < 0.33333:
7 return 0
8- if heat / max_bug_heat < 0.66666:
9+ if heat / max_bug_heat < 0.66666 or max_bug_heat < 2:
10 return int(floor((heat / max_bug_heat) * 4))
11 else:
12- return int(floor((log(heat) / log(max_bug_heat)) * 4))
13+ heat_index = int(floor((log(heat) / log(max_bug_heat)) * 4))
14+ # ensure that we never return a value > 4, even if
15+ # max_bug_heat is outdated.
16+ return min(heat_index, 4)
17
18
19 def bugtask_heat_html(bugtask):
20@@ -1105,8 +1108,9 @@
21 max_bug_heat = 5000
22 heat_ratio = calculate_heat_display(bugtask.bug.heat, max_bug_heat)
23 html = (
24- '<img src="/@@/bug-heat-%(ratio)i.png" '
25+ '<span><img src="/@@/bug-heat-%(ratio)i.png" '
26 'alt="%(ratio)i out of 4 heat flames" title="Heat: %(heat)i" />'
27+ '</span>'
28 % {'ratio': heat_ratio, 'heat': bugtask.bug.heat})
29 return html
30
31
32=== modified file 'lib/lp/bugs/browser/tests/bug-heat-view.txt'
33--- lib/lp/bugs/browser/tests/bug-heat-view.txt 2010-02-26 09:54:20 +0000
34+++ lib/lp/bugs/browser/tests/bug-heat-view.txt 2010-02-28 10:04:17 +0000
35@@ -12,7 +12,7 @@
36 >>> def print_flames(bugtask):
37 ... html = bugtask_heat_html(bugtask)
38 ... soup = BeautifulSoup(html)
39- ... for img in soup.contents:
40+ ... for img in soup.span.contents:
41 ... print img['src']
42 ... print img['alt']
43 ... print img['title']
44@@ -81,3 +81,14 @@
45 >>> print calculate_heat_display(800.0, 1000.0)
46 3
47
48+A max heat value of 1 works too, because we don't divide by
49+log(max_heat) in this case.
50+
51+ >>> print calculate_heat_display(1, 1)
52+ 4
53+
54+Even if the max heat value is smaller than the heat value itself,
55+calculate_heat_display() does not return a value greater than 4.
56+
57+ >>> print calculate_heat_display(2000, 1000)
58+ 4

Subscribers

People subscribed via source and target branches

to status/vote changes: