Optimize show_version_check? helper
What does this MR do and why?
Avoids executing an SQL query for most users. The query will only be executed when the user is an admin.
This method is called twice on every HTML page load:
-
Upgrade alert banner
"app/views/shared/gitlab_version/_security_patch_upgrade_alert.html.haml:1", "app/helpers/application_helper.rb:21:in `dispensable_render'", "app/views/layouts/_page.html.haml:33", "app/views/layouts/application.html.haml:20",
-
Sidebar
"app/helpers/version_check_helper.rb:8:in `show_version_check?'", "app/helpers/sidebars_helper.rb:63:in `super_sidebar_logged_out_context'", "app/helpers/sidebars_helper.rb:73:in `super_sidebar_logged_in_context'", "app/helpers/sidebars_helper.rb:50:in `super_sidebar_context'", "ee/app/helpers/ee/sidebars_helper.rb:37:in `super_sidebar_context'", "app/views/layouts/_page.html.haml:9", "app/views/layouts/application.html.haml:20",
The query is fast and cached on the 2nd call but since this is called on a lot of pages, I think it is worth optimizing.
MR acceptance checklist
This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.
-
I have evaluated the MR acceptance checklist for this MR.
Edited by Heinrich Lee Yu