Replace raw state integers with named enum scopes in jobs#72
Open
JuanVqz wants to merge 2 commits intofix-brakemanfrom
Open
Replace raw state integers with named enum scopes in jobs#72JuanVqz wants to merge 2 commits intofix-brakemanfrom
JuanVqz wants to merge 2 commits intofix-brakemanfrom
Conversation
Using state: 0 relied on knowing the integer value of the approved enum, which breaks silently if values change. Both DailyPuzzleJob and PuzzleInventoryCheckJob now use Puzzle.approved.where(sent_at: nil).
JuanVqz
commented
Mar 6, 2026
|
|
||
| def send_low_inventory_notification(count) | ||
| channel_id = ENV["SHIELD_NOTIFICATIONS_CHANNEL"] | ||
| return Rails.logger.warn("SHIELD_NOTIFICATIONS_CHANNEL is not configured, skipping low inventory notification") unless channel_id |
Member
Author
There was a problem hiding this comment.
nil guard does not fix the issue but discarding factors.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Both
DailyPuzzleJobandPuzzleInventoryCheckJobqueried for approved puzzles using the raw integerstate: 0instead of the named enum scope:The integer
0maps toapprovedtoday per the enum definition, but this is implicit and will silently return wrong results if the enum ever changes.Fix
Tests
Added test files for both jobs (neither had any tests):
DailyPuzzleJobTestsent_atPuzzleInventoryCheckJobTest