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
=== modified file 'lib/lp/bugs/browser/bugtask.py'
--- lib/lp/bugs/browser/bugtask.py 2010-02-27 20:20:03 +0000
+++ lib/lp/bugs/browser/bugtask.py 2010-02-28 10:04:17 +0000
@@ -1092,10 +1092,13 @@
1092 max_bug_heat = float(max_bug_heat)1092 max_bug_heat = float(max_bug_heat)
1093 if heat / max_bug_heat < 0.33333:1093 if heat / max_bug_heat < 0.33333:
1094 return 01094 return 0
1095 if heat / max_bug_heat < 0.66666:1095 if heat / max_bug_heat < 0.66666 or max_bug_heat < 2:
1096 return int(floor((heat / max_bug_heat) * 4))1096 return int(floor((heat / max_bug_heat) * 4))
1097 else:1097 else:
1098 return int(floor((log(heat) / log(max_bug_heat)) * 4))1098 heat_index = int(floor((log(heat) / log(max_bug_heat)) * 4))
1099 # ensure that we never return a value > 4, even if
1100 # max_bug_heat is outdated.
1101 return min(heat_index, 4)
10991102
11001103
1101def bugtask_heat_html(bugtask):1104def bugtask_heat_html(bugtask):
@@ -1105,8 +1108,9 @@
1105 max_bug_heat = 50001108 max_bug_heat = 5000
1106 heat_ratio = calculate_heat_display(bugtask.bug.heat, max_bug_heat)1109 heat_ratio = calculate_heat_display(bugtask.bug.heat, max_bug_heat)
1107 html = (1110 html = (
1108 '<img src="/@@/bug-heat-%(ratio)i.png" '1111 '<span><img src="/@@/bug-heat-%(ratio)i.png" '
1109 'alt="%(ratio)i out of 4 heat flames" title="Heat: %(heat)i" />'1112 'alt="%(ratio)i out of 4 heat flames" title="Heat: %(heat)i" />'
1113 '</span>'
1110 % {'ratio': heat_ratio, 'heat': bugtask.bug.heat})1114 % {'ratio': heat_ratio, 'heat': bugtask.bug.heat})
1111 return html1115 return html
11121116
11131117
=== modified file 'lib/lp/bugs/browser/tests/bug-heat-view.txt'
--- lib/lp/bugs/browser/tests/bug-heat-view.txt 2010-02-26 09:54:20 +0000
+++ lib/lp/bugs/browser/tests/bug-heat-view.txt 2010-02-28 10:04:17 +0000
@@ -12,7 +12,7 @@
12 >>> def print_flames(bugtask):12 >>> def print_flames(bugtask):
13 ... html = bugtask_heat_html(bugtask)13 ... html = bugtask_heat_html(bugtask)
14 ... soup = BeautifulSoup(html)14 ... soup = BeautifulSoup(html)
15 ... for img in soup.contents:15 ... for img in soup.span.contents:
16 ... print img['src']16 ... print img['src']
17 ... print img['alt']17 ... print img['alt']
18 ... print img['title']18 ... print img['title']
@@ -81,3 +81,14 @@
81 >>> print calculate_heat_display(800.0, 1000.0)81 >>> print calculate_heat_display(800.0, 1000.0)
82 382 3
8383
84A max heat value of 1 works too, because we don't divide by
85log(max_heat) in this case.
86
87 >>> print calculate_heat_display(1, 1)
88 4
89
90Even if the max heat value is smaller than the heat value itself,
91calculate_heat_display() does not return a value greater than 4.
92
93 >>> print calculate_heat_display(2000, 1000)
94 4

Subscribers

People subscribed via source and target branches

to status/vote changes: