Skip to content

Commit 55287b3

Browse files
authored
Fix Query Stats tab stuck on loading spinner (#6)
Pre-existing bug unrelated to Phase 1a. The sort dropdown and refresh button in the Query Stats tab partial were commented out (likely in 79a17f7 when sortable column headers replaced the dropdown-based sorting), but the JavaScript that reads their values and attaches event listeners was left in place. When the tab loaded, the JS threw TypeError on the null element, killing loadQueryStats() mid-flight after it showed the spinner but before it issued the fetch — so the spinner sat forever. Fix: delete the commented-out div from _tab_query_stats.html.erb, delete the dead var sort = el('qstats-sort').value line, hardcode sort: 'total_time' in the ajaxGet call (matches the controller's default), and delete the two addEventListener calls for the removed elements. Client-side sortable column headers continue to provide sort UX after data loads. The Dashboard tab's "Top 5 expensive queries" widget was unaffected because it uses its own ajaxGet with hardcoded sort params, which is how Query Stats JSON data was still coming back over the wire even though the UI was broken.
1 parent 0e754bb commit 55287b3

2 files changed

Lines changed: 1 addition & 15 deletions

File tree

app/views/mysql_genius/queries/_tab_query_stats.html.erb

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,6 @@
22
<div class="mg-tab-content" id="tab-qstats">
33
<div class="mg-row" style="justify-content:space-between;align-items:center;margin-bottom:12px;">
44
<div class="mg-text-muted">Top queries from <code>performance_schema.events_statements_summary_by_digest</code>. <span id="qstats-count" class="mg-badge mg-badge-secondary"></span></div>
5-
<!--div>
6-
<label style="display:inline;font-size:12px;margin-right:4px;">Sort by:</label>
7-
<select id="qstats-sort" style="width:auto;display:inline-block;padding:3px 6px;font-size:12px;">
8-
<option value="total_time">Total Time</option>
9-
<option value="avg_time">Avg Time</option>
10-
<option value="calls">Calls</option>
11-
<option value="rows_examined">Rows Examined</option>
12-
</select>
13-
<button id="qstats-refresh" class="mg-btn mg-btn-outline-secondary mg-btn-sm" style="margin-left:4px;">&#8635; Refresh</button>
14-
</div-->
155
</div>
166
<div id="qstats-loading" class="mg-text-center mg-hidden"><span class="mg-spinner"></span> Loading...</div>
177
<div id="qstats-error" class="mg-hidden"></div>

app/views/mysql_genius/queries/index.html.erb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1037,8 +1037,7 @@
10371037
hide(el('qstats-empty')); hide(el('qstats-table-wrapper')); hide(el('qstats-error'));
10381038
el('qstats-tbody').innerHTML = '';
10391039

1040-
var sort = el('qstats-sort').value;
1041-
ajaxGet(ROUTES.query_stats, { sort: sort }, function(data) {
1040+
ajaxGet(ROUTES.query_stats, { sort: 'total_time' }, function(data) {
10421041
hide(el('qstats-loading'));
10431042
if (data.error) {
10441043
el('qstats-error').innerHTML = '<div class="mg-alert mg-alert-warning">' + escHtml(data.error) + '</div>';
@@ -1074,9 +1073,6 @@
10741073
return ms.toFixed(1) + ' ms';
10751074
}
10761075

1077-
el('qstats-refresh').addEventListener('click', loadQueryStats);
1078-
el('qstats-sort').addEventListener('change', loadQueryStats);
1079-
10801076
// --- Unused Indexes ---
10811077

10821078
function loadUnusedIndexes() {

0 commit comments

Comments
 (0)