Skip to content
This repository was archived by the owner on Mar 15, 2025. It is now read-only.

Commit ae22fa1

Browse files
committed
show total query duration in nav subtitle
1 parent 2221896 commit ae22fa1

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

debug_toolbar_sqlalchemy/panel.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
from debug_toolbar.panels import Panel
22
from debug_toolbar_sqlalchemy.operation_tracker import OperationTracker
3+
34
from django.utils.translation import ugettext as _
45
from django.template.loader import render_to_string
56

7+
68
class SqlAlchemyDebugPanel(Panel):
79
""" Panel that shows information about SQLAlchemy operations. """
810
name = 'SQLAlchemy'
@@ -20,7 +22,11 @@ def nav_title(self):
2022
def nav_subtitle(self):
2123
if self.tracker:
2224
count = len(self.tracker.queries)
23-
return "%d %s" % (count, "query" if count == 1 else "queries")
25+
return "%d %s in %.2fms" % (
26+
count,
27+
"query" if count == 1 else "queries",
28+
sum(map(lambda query: query.duration, self.tracker.queries)),
29+
)
2430

2531
return "Unavailable"
2632

@@ -36,4 +42,3 @@ def content(self):
3642
self.template,
3743
{'queries': self.tracker.queries}
3844
)
39-

0 commit comments

Comments
 (0)