From a24d843d4158ce24a0e02087ef1f5b12f341ef2b Mon Sep 17 00:00:00 2001 From: Pilou <8350914+pil0u@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:17:33 +0100 Subject: [PATCH 1/2] Don't break snippet creation when Puzzle does not exist (#734) --- app/controllers/snippets_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 34e1b879..b602b036 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -80,7 +80,7 @@ def client def update_slack_thread puzzle = Puzzle.by_date(Aoc.begin_time.change(day: params[:day])) - return if puzzle.thread_ts.nil? + return if puzzle&.thread_ts.nil? snippets = Snippet.includes(:user).where(day: @snippet.day) part_one, part_two = snippets.partition { |snippet| snippet.challenge == 1 }.map do |solutions| From 3a26afb3c7c5978a1bd43b2518c7d924b9263372 Mon Sep 17 00:00:00 2001 From: Pilou <8350914+pil0u@users.noreply.github.com> Date: Fri, 13 Dec 2024 13:50:50 +0100 Subject: [PATCH 2/2] Reduce default thread numbers from 5 to 2 (#733) * Reduce default thread numbers from 5 to 2 * Reduce max_threads in good_job initializer as well --- config/database.yml | 2 +- config/initializers/good_job.rb | 2 +- config/puma.rb | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/config/database.yml b/config/database.yml index 66cbbaa5..77a4a207 100644 --- a/config/database.yml +++ b/config/database.yml @@ -19,7 +19,7 @@ default: &default encoding: unicode # For details on connection pooling, see Rails configuration guide # https://guides.rubyonrails.org/configuring.html#database-pooling - pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> + pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 2 } %> username: <%= ENV.fetch("POSTGRES_USER") { "postgres" } %> password: <%= ENV.fetch("POSTGRES_PASSWORD") { "postgres" } %> diff --git a/config/initializers/good_job.rb b/config/initializers/good_job.rb index 034d6f68..200e339b 100644 --- a/config/initializers/good_job.rb +++ b/config/initializers/good_job.rb @@ -5,7 +5,7 @@ Rails.application.configure do config.good_job = { execution_mode: :external, - max_threads: 5, + max_threads: 2, shutdown_timeout: 30, enable_cron: true, cron: { diff --git a/config/puma.rb b/config/puma.rb index e663c140..29b90b92 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -6,7 +6,7 @@ # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum; this matches the default thread size of Active Record. # -max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5) +max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 2) min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count } threads min_threads_count, max_threads_count