aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Cramer2011-06-10 02:30:36 -0700
committerDavid Cramer2011-06-10 02:30:36 -0700
commit64edae3d5815f9f865fac001b3a39d57944c6465 (patch)
tree8f9bf6eee9e0b7f0a6200f97d92cd04bc858c6b4
parent929c6be2e50b662ee8dc73f40028d832323ef610 (diff)
parent9d32eb2c36f353565ee5738cd92805c1ea11d742 (diff)
downloaddjango-debug-toolbar-64edae3d5815f9f865fac001b3a39d57944c6465.tar.bz2
Merge pull request #173 from thinred/master
SQL panel fix for locales that use comma as a decimal separator.
-rw-r--r--debug_toolbar/panels/sql.py2
-rw-r--r--debug_toolbar/templates/debug_toolbar/panels/sql.html3
-rw-r--r--debug_toolbar/templatetags/__init__.py0
-rw-r--r--debug_toolbar/templatetags/debug_toolbar_utils.py11
4 files changed, 15 insertions, 1 deletions
diff --git a/debug_toolbar/panels/sql.py b/debug_toolbar/panels/sql.py
index c6b5996..bce769a 100644
--- a/debug_toolbar/panels/sql.py
+++ b/debug_toolbar/panels/sql.py
@@ -183,8 +183,10 @@ class SQLDebugPanel(DebugPanel):
query['rgb_color'] = self._databases[alias]['rgb_color']
try:
query['width_ratio'] = (query['duration'] / self._sql_time) * 100
+ query['width_ratio_relative'] = 100.0 * query['width_ratio'] / (100.0 - width_ratio_tally)
except ZeroDivisionError:
query['width_ratio'] = 0
+ query['width_ratio_relative'] = 0
query['start_offset'] = width_ratio_tally
query['end_offset'] = query['width_ratio'] + query['start_offset']
width_ratio_tally += query['width_ratio']
diff --git a/debug_toolbar/templates/debug_toolbar/panels/sql.html b/debug_toolbar/templates/debug_toolbar/panels/sql.html
index f6f231c..9b282ca 100644
--- a/debug_toolbar/templates/debug_toolbar/panels/sql.html
+++ b/debug_toolbar/templates/debug_toolbar/panels/sql.html
@@ -1,4 +1,5 @@
{% load i18n %}
+{% load debug_toolbar_utils %}
<div class="clearfix">
<ul class="stats">
{% for alias, info in databases %}
@@ -34,7 +35,7 @@
</div>
</td>
<td class="timeline">
- <div class="djDebugTimeline"><div class="djDebugLineChart{% if query.is_slow %} djDebugLineChartWarning{% endif %}" style="left:{{ query.start_offset }}%;"><strong style="width:{{ query.width_ratio }}%;">{{ query.width_ratio }}%</strong></div></div>
+ <div class="djDebugTimeline"><div class="djDebugLineChart{% if query.is_slow %} djDebugLineChartWarning{% endif %}" style="left:{{ query.start_offset|dotted_number }}%;"><strong style="width:{{ query.width_ratio_relative|dotted_number }}%;">{{ query.width_ratio }}%</strong></div></div>
</td>
<td class="time">
{{ query.duration|floatformat:"2" }}
diff --git a/debug_toolbar/templatetags/__init__.py b/debug_toolbar/templatetags/__init__.py
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/debug_toolbar/templatetags/__init__.py
diff --git a/debug_toolbar/templatetags/debug_toolbar_utils.py b/debug_toolbar/templatetags/debug_toolbar_utils.py
new file mode 100644
index 0000000..6b204eb
--- /dev/null
+++ b/debug_toolbar/templatetags/debug_toolbar_utils.py
@@ -0,0 +1,11 @@
+
+from django import template
+from django.utils.numberformat import format
+
+register = template.Library()
+
+@register.filter
+def dotted_number(number):
+ number = float(number)
+ return format(number, '.', 6)
+