diff options
| author | David Wolfe | 2014-02-08 18:37:43 -0400 | 
|---|---|---|
| committer | David Wolfe | 2014-02-08 19:39:30 -0400 | 
| commit | 6041b0da8317b3c8df2d1551f8282a9e59c336c3 (patch) | |
| tree | 99405ed7bd34ed08a0efe87f1287e4f28d649751 /debug_toolbar/panels/sql/panel.py | |
| parent | 1449c014ed449c7c139e2912b0ebb063b1134c83 (diff) | |
| download | django-debug-toolbar-6041b0da8317b3c8df2d1551f8282a9e59c336c3.tar.bz2 | |
Color-code SQL query "Timeline" stripes according to stacktrace
Diffstat (limited to 'debug_toolbar/panels/sql/panel.py')
| -rw-r--r-- | debug_toolbar/panels/sql/panel.py | 9 | 
1 files changed, 8 insertions, 1 deletions
| diff --git a/debug_toolbar/panels/sql/panel.py b/debug_toolbar/panels/sql/panel.py index 2534849..cae5214 100644 --- a/debug_toolbar/panels/sql/panel.py +++ b/debug_toolbar/panels/sql/panel.py @@ -10,7 +10,7 @@ from django.utils.translation import ugettext_lazy as _, ungettext_lazy as __  from debug_toolbar.panels import Panel  from debug_toolbar.panels.sql.forms import SQLSelectForm  from debug_toolbar.utils import render_stacktrace -from debug_toolbar.panels.sql.utils import reformat_sql +from debug_toolbar.panels.sql.utils import reformat_sql, contrasting_color_generator  from debug_toolbar.panels.sql.tracking import wrap_cursor, unwrap_cursor @@ -136,6 +136,8 @@ class SQLPanel(Panel):              unwrap_cursor(connection)      def process_response(self, request, response): +        colors = contrasting_color_generator() +        trace_colors = {}          if self._queries:              width_ratio_tally = 0              factor = int(256.0 / (len(self._databases) * 2.5)) @@ -196,6 +198,11 @@ class SQLPanel(Panel):                  query['stacktrace'] = render_stacktrace(query['stacktrace'])                  i += 1 +                if not trace_colors.get(query['stacktrace']): +                    c = colors.next() +                    trace_colors[query['stacktrace']] = c +                query['trace_color'] = trace_colors[query['stacktrace']] +              if trans_id:                  self._queries[(i - 1)][1]['ends_trans'] = True | 
