From 77193cdf35fddc184c24eeeebc52aef0514200c0 Mon Sep 17 00:00:00 2001 From: Nelson Jovel Date: Thu, 21 Dec 2023 13:34:16 -0800 Subject: [PATCH] fix: reduce number of n+1 queries --- .ruby-version | 2 +- Gemfile | 2 +- Gemfile.lock | 77 +++++++++++++++++--------- app/controllers/overview_controller.rb | 2 +- app/models/category.rb | 1 - 5 files changed, 55 insertions(+), 29 deletions(-) diff --git a/.ruby-version b/.ruby-version index be94e6f5..15a27998 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -3.2.2 +3.3.0 diff --git a/Gemfile b/Gemfile index 258f5777..07a492f1 100644 --- a/Gemfile +++ b/Gemfile @@ -1,5 +1,5 @@ source "https://rubygems.org" -ruby "3.2.2" +ruby "3.3.0" git_source(:github) do |repo_name| repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") diff --git a/Gemfile.lock b/Gemfile.lock index 1ab1d194..20bb91ac 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -104,11 +104,12 @@ GEM parser (>= 2.4) smart_properties bigdecimal (3.1.5) - bootsnap (1.17.0) + bootsnap (1.17.1) msgpack (~> 1.2) - brakeman (6.1.0) + brakeman (6.1.1) + racc builder (3.2.4) - bullet (7.1.4) + bullet (7.1.5) activesupport (>= 3.0.0) uniform_notifier (~> 1.11) byebug (11.1.3) @@ -145,6 +146,33 @@ GEM railties (>= 3.2) drb (2.2.0) ruby2_keywords + dry-configurable (1.1.0) + dry-core (~> 1.0, < 2) + zeitwerk (~> 2.6) + dry-core (1.0.1) + concurrent-ruby (~> 1.0) + zeitwerk (~> 2.6) + dry-inflector (1.0.0) + dry-initializer (3.1.1) + dry-logic (1.5.0) + concurrent-ruby (~> 1.0) + dry-core (~> 1.0, < 2) + zeitwerk (~> 2.6) + dry-schema (1.13.3) + concurrent-ruby (~> 1.0) + dry-configurable (~> 1.0, >= 1.0.1) + dry-core (~> 1.0, < 2) + dry-initializer (~> 3.0) + dry-logic (>= 1.4, < 2) + dry-types (>= 1.7, < 2) + zeitwerk (~> 2.6) + dry-types (1.7.2) + bigdecimal (~> 3.0) + concurrent-ruby (~> 1.0) + dry-core (~> 1.0) + dry-inflector (~> 1.0) + dry-logic (~> 1.4) + zeitwerk (~> 2.6) e2mmap (0.1.0) ed25519 (1.3.0) em-websocket (0.5.3) @@ -160,9 +188,9 @@ GEM erblint-github (0.5.1) erubi (1.12.0) eventmachine (1.2.7) - factory_bot (6.4.2) + factory_bot (6.4.5) activesupport (>= 5.0.0) - factory_bot_rails (6.4.2) + factory_bot_rails (6.4.3) factory_bot (~> 6.4) railties (>= 5.0.0) ferrum (0.14) @@ -199,18 +227,17 @@ GEM i18n (1.14.1) concurrent-ruby (~> 1.0) io-console (0.7.1) - irb (1.10.1) + irb (1.11.1) rdoc - reline (>= 0.3.8) + reline (>= 0.4.2) jaro_winkler (1.5.6) - jsbundling-rails (1.2.1) + jsbundling-rails (1.2.2) railties (>= 6.0.0) json (2.7.1) kramdown (2.4.0) rexml kramdown-parser-gfm (1.1.0) kramdown (~> 2.0) - kwalify (0.7.2) language_server-protocol (3.17.0.3) launchy (2.5.2) addressable (~> 2.8) @@ -230,13 +257,13 @@ GEM matrix (0.4.2) method_source (1.0.0) mini_mime (1.1.5) - minitest (5.20.0) + minitest (5.21.1) msgpack (1.7.2) multi_json (1.15.0) mutex_m (0.2.0) nenv (0.3.0) nested_scaffold (1.1.0) - net-imap (0.4.8) + net-imap (0.4.9.1) date net-protocol net-pop (0.1.2) @@ -245,24 +272,23 @@ GEM timeout net-sftp (4.0.0) net-ssh (>= 5.0.0, < 8.0.0) - net-smtp (0.4.0) + net-smtp (0.4.0.1) net-protocol net-ssh (7.2.1) - newrelic_rpm (9.6.0) - base64 + newrelic_rpm (9.7.0) nio4r (2.7.0) - nokogiri (1.15.5-arm64-darwin) + nokogiri (1.16.0-arm64-darwin) racc (~> 1.4) - nokogiri (1.15.5-x86_64-darwin) + nokogiri (1.16.0-x86_64-darwin) racc (~> 1.4) - nokogiri (1.15.5-x86_64-linux) + nokogiri (1.16.0-x86_64-linux) racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) orm_adapter (0.5.0) parallel (1.24.0) - parallel_tests (4.3.0) + parallel_tests (4.4.0) parallel parser (3.2.2.4) ast (~> 2.4.1) @@ -274,7 +300,7 @@ GEM psych (5.1.2) stringio public_suffix (5.0.4) - puma (6.4.0) + puma (6.4.2) nio4r (~> 2.0) racc (1.7.3) rack (3.0.8) @@ -330,12 +356,13 @@ GEM rbs (2.8.4) rdoc (6.6.2) psych (>= 4.0.0) - reek (6.1.4) - kwalify (~> 0.7.0) + reek (6.2.0) + dry-schema (~> 1.13.0) parser (~> 3.2.0) rainbow (>= 2.0, < 4.0) - regexp_parser (2.8.3) - reline (0.3.9) + rexml (~> 3.1) + regexp_parser (2.9.0) + reline (0.4.2) io-console (~> 0.5) responders (3.1.1) actionpack (>= 5.2) @@ -423,7 +450,7 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) standard_deviation (1.0.3) - stimulus-rails (1.3.0) + stimulus-rails (1.3.3) railties (>= 6.0.0) stringio (3.1.0) thor (1.3.0) @@ -508,7 +535,7 @@ DEPENDENCIES watir RUBY VERSION - ruby 3.2.2p53 + ruby 3.3.0p0 BUNDLED WITH 2.3.3 diff --git a/app/controllers/overview_controller.rb b/app/controllers/overview_controller.rb index 28dc4c6c..8e78cd25 100644 --- a/app/controllers/overview_controller.rb +++ b/app/controllers/overview_controller.rb @@ -37,6 +37,6 @@ class OverviewController < SqmApplicationController end def categories - @categories ||= Category.sorted.includes(%i[measures scales admin_data_items subcategories]) + @categories ||= Category.sorted.includes(%i[measures admin_data_items subcategories]) end end diff --git a/app/models/category.rb b/app/models/category.rb index ad546a98..318d3f5f 100644 --- a/app/models/category.rb +++ b/app/models/category.rb @@ -9,5 +9,4 @@ class Category < ActiveRecord::Base has_many :subcategories has_many :measures, through: :subcategories has_many :admin_data_items, through: :measures - has_many :scales, through: :subcategories end