File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -3,10 +3,10 @@ class PuzzleInventoryCheckJob < ApplicationJob
33 retry_on StandardError , attempts : 3
44
55 def perform
6- approved_unsent_puzzle_count = Puzzle . where ( state : 0 , sent_at : nil ) . count
6+ approved_puzzle_count = Puzzle . where ( state : 0 ) . count
77
8- if approved_unsent_puzzle_count < 5
9- send_low_inventory_notification ( approved_unsent_puzzle_count )
8+ if approved_puzzle_count < 5
9+ send_low_inventory_notification ( approved_puzzle_count )
1010 end
1111 end
1212
@@ -16,4 +16,10 @@ def send_low_inventory_notification(count)
1616 notification_message = SlackClient ::Messages ::LowPuzzleInventoryNotification . new ( count ) . create
1717 send_message ( notification_message , channel_id : ENV . fetch ( "SHIELD_NOTIFICATIONS_CHANNEL" , nil ) )
1818 end
19+
20+ def send_message ( message , channel_id :)
21+ SlackClient ::Client . instance . chat_postMessage ( channel : channel_id , blocks : message )
22+ rescue Slack ::Web ::Api ::Errors ::SlackError
23+ head :unprocessable_entity
24+ end
1925end
You can’t perform that action at this time.
0 commit comments