Fix Query Stats tab stuck on loading spinner#6
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
The Query Stats tab was stuck showing its loading spinner indefinitely. Root cause: the sort dropdown and refresh button in
_tab_query_stats.html.erbwere commented out (in commit79a17f7, when sortable column headers were introduced as a replacement), but the JavaScript that readsel('qstats-sort').valueand attaches listeners to#qstats-refresh/#qstats-sortwas left in place. When the tab loaded,loadQueryStats()showed the spinner, then threwTypeError: Cannot read properties of null (reading 'value')on the dropdown read — the fetch was never issued and the spinner stayed up forever.The Dashboard tab's "Top 5 expensive queries" widget was unaffected because it uses its own
ajaxGet(ROUTES.query_stats, { sort: 'total_time', limit: 5 }, ...)call that doesn't touch the removed DOM elements.Fix
<!--div>...</div-->block from_tab_query_stats.html.erbvar sort = el('qstats-sort').value;line fromloadQueryStats()inindex.html.erbsort: 'total_time'in theajaxGetcall (matches the controller's default)addEventListenercalls for the non-existent elementsClient-side sortable column headers (added in
79a17f7) continue to provide sort UX after the data loads.Context
Originally committed as
37dbf8eon thefeature/mysql-genius-core-phase-1abranch (PR #5) where it was a pre-existing-bug drive-by fix uncovered during testing. Cherry-picked here as a standalone PR so the fix can land on main independently of the larger Phase 1a refactor. When PR #5 merges, git's 3-way merge will detect the identical change already on main and merge cleanly without conflict or duplication.Test Plan
mysql_genius