Skip to content

Commit ab02c69

Browse files
committed
Merge remote-tracking branch 'origin/pr/109'
Conflicts: src/DebugBar/Resources/widgets/sqlqueries/widget.css
2 parents 6f58aee + 7c0c9c7 commit ab02c69

File tree

2 files changed

+33
-2
lines changed

2 files changed

+33
-2
lines changed

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

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
div.phpdebugbar-widgets-sqlqueries .phpdebugbar-widgets-status {
32
font-family: monospace;
43
padding: 6px 6px;
@@ -67,8 +66,17 @@ div.phpdebugbar-widgets-sqlqueries li.phpdebugbar-widgets-list-item span.phpdebu
6766
display: block;
6867
font-weight: bold;
6968
}
69+
7070
code.phpdebugbar-widgets-sql {
7171
white-space: pre-wrap;
7272
overflow-wrap: break-word;
7373
word-wrap: break-word;
74-
}
74+
}
75+
76+
div.phpdebugbar-widgets-sqlqueries li.phpdebugbar-widgets-list-item.phpdebugbar-widgets-sql-duplicate {
77+
background-color: #ffd;
78+
}
79+
80+
div.phpdebugbar-widgets-sqlqueries li.phpdebugbar-widgets-list-item.phpdebugbar-widgets-sql-duplicate:hover {
81+
background-color: #ffc;
82+
}

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,33 @@
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+
if (data.statements[i].params && !$.isEmptyObject(data.statements[i].params)) {
60+
stmt += ' {' + $.param(data.statements[i].params, false) + '}';
61+
}
62+
sql[stmt] = sql[stmt] || { keys: [] };
63+
sql[stmt].keys.push(i);
64+
}
65+
// Add classes to all duplicate SQL statements.
66+
for (var stmt in sql) {
67+
if (sql[stmt].keys.length > 1) {
68+
duplicate++;
69+
for (var i = 0; i < sql[stmt].keys.length; i++) {
70+
this.$list.$el.find('.' + csscls('list-item')).eq(sql[stmt].keys[i])
71+
.addClass(csscls('sql-duplicate')).addClass(csscls('sql-duplicate-'+duplicate));
72+
}
73+
}
74+
}
75+
5676
var t = $('<span />').text(data.nb_statements + " statements were executed").appendTo(this.$status);
5777
if (data.nb_failed_statements) {
5878
t.append(", " + data.nb_failed_statements + " of which failed");
5979
}
80+
if (duplicate) {
81+
t.append(", " + duplicate + " of which were duplicated");
82+
}
6083
if (data.accumulated_duration_str) {
6184
this.$status.append($('<span title="Accumulated duration" />').addClass(csscls('duration')).text(data.accumulated_duration_str));
6285
}

0 commit comments

Comments
 (0)