diff --git a/Gemfile b/Gemfile index a85fd4e0..7a91981e 100644 --- a/Gemfile +++ b/Gemfile @@ -81,6 +81,7 @@ group :development, :staging, :test do end group :development, :test do + gem 'bullet' # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: %i[mri mingw x64_mingw] # Use sqlite3 as the database for Active Record diff --git a/Gemfile.lock b/Gemfile.lock index cacde31c..69531189 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -108,6 +108,9 @@ GEM popper_js (>= 2.11.8, < 3) browser (5.3.1) builder (3.2.4) + bullet (7.1.6) + activesupport (>= 3.0.0) + uniform_notifier (~> 1.11) byebug (11.1.3) capybara (3.40.0) addressable @@ -280,6 +283,7 @@ GEM net-smtp (0.4.0.1) net-protocol nio4r (2.7.0) + racc (~> 1.4) nokogiri (1.16.2-arm64-darwin) racc (~> 1.4) nokogiri (1.16.2-x86_64-darwin) @@ -523,6 +527,7 @@ GEM tzinfo (2.0.6) concurrent-ruby (~> 1.0) unicode-display_width (2.5.0) + uniform_notifier (1.16.0) uri (0.13.0) valid_email2 (5.2.1) activemodel (>= 3.2) @@ -570,6 +575,7 @@ DEPENDENCIES bootsnap bootstrap browser + bullet byebug capybara cocoon diff --git a/app/controllers/web/admin/vacancies_controller.rb b/app/controllers/web/admin/vacancies_controller.rb index 202b03c1..c7bfadd8 100644 --- a/app/controllers/web/admin/vacancies_controller.rb +++ b/app/controllers/web/admin/vacancies_controller.rb @@ -3,16 +3,15 @@ class Web::Admin::VacanciesController < Web::Admin::ApplicationController def index query = query_params({ s: 'created_at desc' }) + scope = Vacancy.includes(:creator).with_locale + @q = scope.ransack(query) respond_to do |format| format.html do @go_to = admin_vacancies_path(page: params[:page]) - @q = Vacancy.with_locale.ransack(query) @vacancies = @q.result(distinct: true).page(params[:page]) end - format.csv do - q = Vacancy.with_locale.includes(:creator).ransack(query) - vacancies = q.result(distinct: true) + vacancies = @q.result(distinct: true) headers = %w[id title state creator company_name created_at published_at] send_file_headers!(filename: "vacancies-#{Time.zone.today}.csv") diff --git a/config/environments/development.rb b/config/environments/development.rb index e5fe9ce0..66cf45b4 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -50,6 +50,16 @@ # Highlight code that triggered database queries in logs. config.active_record.verbose_query_logs = true + config.after_initialize do + Bullet.enable = true + Bullet.alert = false + Bullet.bullet_logger = true + Bullet.console = false + Bullet.rails_logger = true + Bullet.sentry = true + Bullet.add_footer = false + end + # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. diff --git a/config/environments/test.rb b/config/environments/test.rb index eb36dfc5..554ac024 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -8,6 +8,12 @@ Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. + config.after_initialize do + Bullet.enable = true + Bullet.bullet_logger = true + Bullet.raise = true + end + config.cache_classes = false # Do not eager load code on boot. This avoids loading your whole application