File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -3,10 +3,10 @@ class PuzzleInventoryCheckJob < ApplicationJob
3
3
retry_on StandardError , attempts : 3
4
4
5
5
def perform
6
- approved_unsent_puzzle_count = Puzzle . where ( state : 0 , sent_at : nil ) . count
6
+ approved_puzzle_count = Puzzle . where ( state : 0 ) . count
7
7
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 )
10
10
end
11
11
end
12
12
@@ -16,4 +16,10 @@ def send_low_inventory_notification(count)
16
16
notification_message = SlackClient ::Messages ::LowPuzzleInventoryNotification . new ( count ) . create
17
17
send_message ( notification_message , channel_id : ENV . fetch ( "SHIELD_NOTIFICATIONS_CHANNEL" , nil ) )
18
18
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
19
25
end
You can’t perform that action at this time.
0 commit comments