diff --git a/app/.rubocop.yml b/app/.rubocop.yml index 1ac2362..f157647 100644 --- a/app/.rubocop.yml +++ b/app/.rubocop.yml @@ -21,6 +21,7 @@ Metrics/AbcSize: Metrics/BlockLength: Exclude: - 'spec/**/*_spec.rb' + - 'config/environments/development.rb' Metrics/MethodLength: Exclude: diff --git a/app/Gemfile b/app/Gemfile index 17798ef..7e231b0 100644 --- a/app/Gemfile +++ b/app/Gemfile @@ -22,6 +22,7 @@ gem 'turbo-rails' gem 'tzinfo-data' group :development, :test do + gem 'bullet' gem 'debug', platforms: %i[mri windows] gem 'factory_bot_rails' gem 'faker' diff --git a/app/Gemfile.lock b/app/Gemfile.lock index b0f206d..516a906 100644 --- a/app/Gemfile.lock +++ b/app/Gemfile.lock @@ -93,6 +93,9 @@ GEM bootsnap (1.18.4) msgpack (~> 1.2) builder (3.3.0) + bullet (7.2.0) + activesupport (>= 3.0.0) + uniform_notifier (~> 1.11) concurrent-ruby (1.3.4) connection_pool (2.4.1) crass (1.0.6) @@ -353,6 +356,7 @@ GEM tzinfo-data (1.2024.1) tzinfo (>= 1.0.0) unicode-display_width (2.5.0) + uniform_notifier (1.16.0) uri (0.13.0) useragent (0.16.10) version_gem (1.1.4) @@ -370,6 +374,7 @@ PLATFORMS DEPENDENCIES aws-sdk-s3 bootsnap + bullet debug factory_bot_rails faker diff --git a/app/app/controllers/admin/game_schedules_controller.rb b/app/app/controllers/admin/game_schedules_controller.rb index 0bdd2bb..10e877e 100644 --- a/app/app/controllers/admin/game_schedules_controller.rb +++ b/app/app/controllers/admin/game_schedules_controller.rb @@ -7,6 +7,7 @@ class GameSchedulesController < ApplicationController def index @game_schedules = GameSchedule.start_at_ordered .search_by_keyword(index_params[:search]) + .preload(:season, :tournament, :home_team, :visitor_team, :game_field) .page(index_params[:page]) .per(INDEX_PER_PAGE) end diff --git a/app/app/controllers/admin/media_page_settings_controller.rb b/app/app/controllers/admin/media_page_settings_controller.rb index f1a43fa..e66dac9 100644 --- a/app/app/controllers/admin/media_page_settings_controller.rb +++ b/app/app/controllers/admin/media_page_settings_controller.rb @@ -3,7 +3,7 @@ module Admin class MediaPageSettingsController < ApplicationController def show - @media_hero_images = MediaHeroImage.sort_order_ordered + @media_hero_images = MediaHeroImage.preload(image_attachment: :blob).sort_order_ordered end end end diff --git a/app/app/controllers/media/game_schedules_controller.rb b/app/app/controllers/media/game_schedules_controller.rb index b635457..9f6d451 100644 --- a/app/app/controllers/media/game_schedules_controller.rb +++ b/app/app/controllers/media/game_schedules_controller.rb @@ -12,7 +12,7 @@ def index game_schedules = GameSchedule.start_at_ordered .game_field_ordered .where(season: @season) - .preload(:home_team, :visitor_team, :game_field, :tournament) + .preload(:home_team, :visitor_team, :game_field, :tournament, :game_result) # group by date. @game_schedule_groups = game_schedules.group_by { |game_schedule| game_schedule.start_at.to_date } diff --git a/app/app/controllers/media/homes_controller.rb b/app/app/controllers/media/homes_controller.rb index 3202e7c..aa9a6d7 100644 --- a/app/app/controllers/media/homes_controller.rb +++ b/app/app/controllers/media/homes_controller.rb @@ -6,12 +6,14 @@ class HomesController < ApplicationController def show @media_hero_images = MediaHeroImage.sort_order_ordered + .preload(image_attachment: :blob) @notices = Notice.only_published .published_at_ordered .limit(NOTICES_LIMIT) @game_schedules = GameSchedule.next_scheduled_games + .preload(:game_field, :tournament, :home_team, :visitor_team, :game_result) end end end diff --git a/app/app/views/admin/game_schedules/_form.html.haml b/app/app/views/admin/game_schedules/_form.html.haml index 8f39401..3b03c8d 100644 --- a/app/app/views/admin/game_schedules/_form.html.haml +++ b/app/app/views/admin/game_schedules/_form.html.haml @@ -31,7 +31,7 @@ = GameSchedule.human_attribute_name(:home_team) .admin-field__value = form.select_with_image(:home_team_id, - Team.all, + Team.preload({ logo_attachment: :blob }), value_method: :id, text_method: :name, image_method: :logo_url, @@ -43,7 +43,7 @@ = GameSchedule.human_attribute_name(:visitor_team) .admin-field__value = form.select_with_image(:visitor_team_id, - Team.all, + Team.preload({ logo_attachment: :blob }), value_method: :id, text_method: :name, image_method: :logo_url, diff --git a/app/config/environments/development.rb b/app/config/environments/development.rb index f45efa3..2ca5b50 100644 --- a/app/config/environments/development.rb +++ b/app/config/environments/development.rb @@ -69,4 +69,15 @@ # Apply autocorrection by RuboCop to files generated by `bin/rails generate`. # config.generators.apply_rubocop_autocorrect_after_generate! + + config.after_initialize do + Bullet.enable = true + Bullet.alert = true + Bullet.rails_logger = true + Bullet.add_footer = true + Bullet.skip_html_injection = false + + Bullet.add_safelist type: :unused_eager_loading, class_name: 'ActiveStorage::Attachment', + association: :blob + end end