Skip to content

Commit

Permalink
Drop unneeded SQLPanel._num_queries attribute
Browse files Browse the repository at this point in the history
The same information can be retrieved from len(self._queries).
  • Loading branch information
living180 committed May 17, 2023
1 parent 79afff4 commit 031dfc6
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions debug_toolbar/panels/sql/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ class SQLPanel(Panel):
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self._sql_time = 0
self._num_queries = 0
self._queries = []
self._databases = {}
# synthetic transaction IDs, keyed by DB alias
Expand Down Expand Up @@ -151,20 +150,20 @@ def record(self, **kwargs):
self._databases[alias]["time_spent"] += kwargs["duration"]
self._databases[alias]["num_queries"] += 1
self._sql_time += kwargs["duration"]
self._num_queries += 1

# Implement the Panel API

nav_title = _("SQL")

@property
def nav_subtitle(self):
query_count = len(self._queries)
return ngettext(
"%(query_count)d query in %(sql_time).2fms",
"%(query_count)d queries in %(sql_time).2fms",
self._num_queries,
query_count,
) % {
"query_count": self._num_queries,
"query_count": query_count,
"sql_time": self._sql_time,
}

Expand Down

0 comments on commit 031dfc6

Please sign in to comment.