Skip to content

Commit 7ed8f13

Browse files
committed
Add classes to all duplicate SQL statement rows.
1 parent 57403a8 commit 7ed8f13

File tree

1 file changed

+20
-0
lines changed
  • src/DebugBar/Resources/widgets/sqlqueries

1 file changed

+20
-0
lines changed

src/DebugBar/Resources/widgets/sqlqueries/widget.js

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,30 @@
5353
this.$list.set('data', data.statements);
5454
this.$status.empty();
5555

56+
// Search for duplicate statements.
57+
for (var sql = {}, duplicate = 0, i = 0; i < data.statements.length; i++) {
58+
var stmt = data.statements[i].sql;
59+
sql[stmt] = sql[stmt] || { keys: [] };
60+
sql[stmt].keys.push(i);
61+
}
62+
// Add classes to all duplicate SQL statements.
63+
for (var stmt in sql) {
64+
if (sql[stmt].keys.length > 1) {
65+
duplicate++;
66+
for (var i = 0; i < sql[stmt].keys.length; i++) {
67+
this.$list.$el.find('.' + csscls('list-item')).eq(sql[stmt].keys[i])
68+
.addClass(csscls('sql-duplicate')).addClass(csscls('sql-duplicate-'+duplicate));
69+
}
70+
}
71+
}
72+
5673
var t = $('<span />').text(data.nb_statements + " statements were executed").appendTo(this.$status);
5774
if (data.nb_failed_statements) {
5875
t.append(", " + data.nb_failed_statements + " of which failed");
5976
}
77+
if (duplicate) {
78+
t.append(", " + duplicate + " of which were duplicates");
79+
}
6080
if (data.accumulated_duration_str) {
6181
this.$status.append($('<span title="Accumulated duration" />').addClass(csscls('duration')).text(data.accumulated_duration_str));
6282
}

0 commit comments

Comments
 (0)