diff --git a/app/controllers/overview_controller.rb b/app/controllers/overview_controller.rb index 9e15112a..0ebb0921 100644 --- a/app/controllers/overview_controller.rb +++ b/app/controllers/overview_controller.rb @@ -23,10 +23,10 @@ class OverviewController < SqmApplicationController end def measures - @measures ||= Measure.all.includes(%i[scales admin_data_items category]) + @measures ||= Measure.all.includes(%i[scales admin_data_items category]).load_async end def subcategories - @subcategories ||= Subcategory.all + @subcategories ||= Subcategory.all.load_async end end diff --git a/app/controllers/sqm_application_controller.rb b/app/controllers/sqm_application_controller.rb index c0061866..90a53893 100644 --- a/app/controllers/sqm_application_controller.rb +++ b/app/controllers/sqm_application_controller.rb @@ -7,11 +7,11 @@ class SqmApplicationController < ApplicationController def set_schools_and_districts @district = District.find_by_slug district_slug - @districts = District.all.order(:name) + @districts = District.all.order(:name).load_async @school = School.find_by_slug(school_slug) - @schools = School.includes([:district]).where(district: @district).order(:name) + @schools = School.includes([:district]).where(district: @district).order(:name).load_async @academic_year = AcademicYear.find_by_range params[:year] - @academic_years = AcademicYear.all.order(range: :desc) + @academic_years = AcademicYear.all.order(range: :desc).load_async end def district_slug diff --git a/config/environments/development.rb b/config/environments/development.rb index a73fd411..f497c5cb 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -71,4 +71,5 @@ Rails.application.configure do config.file_watcher = ActiveSupport::EventedFileUpdateChecker config.action_controller.include_all_helpers = false + config.active_record.async_query_executor = :global_thread_pool end diff --git a/config/environments/production.rb b/config/environments/production.rb index 6609cef7..91121d12 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -111,4 +111,5 @@ Rails.application.configure do # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session config.action_controller.include_all_helpers = false + config.active_record.async_query_executor = :global_thread_pool end