Skip to content

Commit 2b8689c

Browse files
authored
Revert "Replace raw state integers with named enum scopes in jobs (#72)"
This reverts commit 8e304fc.
1 parent 8e304fc commit 2b8689c

File tree

4 files changed

+3
-162
lines changed

4 files changed

+3
-162
lines changed

app/jobs/daily_puzzle_job.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class DailyPuzzleJob < ApplicationJob
33
retry_on StandardError, attempts: 3
44

55
def perform
6-
puzzle = Puzzle.approved.where(sent_at: nil).order("RANDOM()").first
6+
puzzle = Puzzle.where(sent_at: nil, state: 0).order("RANDOM()").first
77
return unless puzzle
88

99
Server.where(active: true).each do |server|

app/jobs/puzzle_inventory_check_job.rb

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ class PuzzleInventoryCheckJob < ApplicationJob
33
retry_on StandardError, attempts: 3
44

55
def perform
6-
approved_unsent_puzzle_count = Puzzle.approved.where(sent_at: nil).count
6+
approved_unsent_puzzle_count = Puzzle.where(state: 0, sent_at: nil).count
77

88
if approved_unsent_puzzle_count < 5
99
send_low_inventory_notification(approved_unsent_puzzle_count)
@@ -13,17 +13,13 @@ def perform
1313
private
1414

1515
def send_low_inventory_notification(count)
16-
channel_id = ENV["SHIELD_NOTIFICATIONS_CHANNEL"]
17-
return Rails.logger.warn("SHIELD_NOTIFICATIONS_CHANNEL is not configured, skipping low inventory notification") unless channel_id
18-
1916
notification_message = SlackClient::Messages::LowPuzzleInventoryNotification.new(count).create
20-
send_message(notification_message, channel_id: channel_id)
17+
send_message(notification_message, channel_id: ENV.fetch("SHIELD_NOTIFICATIONS_CHANNEL", nil))
2118
end
2219

2320
def send_message(message, channel_id:)
2421
SlackClient::Client.instance.chat_postMessage(channel: channel_id, blocks: message)
2522
rescue Slack::Web::Api::Errors::SlackError => e
26-
Sentry.capture_exception(e)
2723
Rails.logger.error "Failed to send Slack message: #{e.message} #{e.response_metadata}"
2824
end
2925
end

test/jobs/daily_puzzle_job_test.rb

Lines changed: 0 additions & 67 deletions
This file was deleted.

test/jobs/puzzle_inventory_check_job_test.rb

Lines changed: 0 additions & 88 deletions
This file was deleted.

0 commit comments

Comments
 (0)