fix: correct off-by-one in getJobs default end index - #1030
Open
tsushanth wants to merge 1 commit into
Open
Conversation
Redis LRANGE and ZRANGE use inclusive bounds, so lrange(key, 0, 100) returns 101 elements. The default `end: 100` was inconsistent with the `size: 100` default used for set-based queue types (failed/succeeded). Change the default to `end: 99` so that a no-argument getJobs() call returns at most 100 jobs for all queue types, matching the documented intent.
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
Queue#getJobsdefaults to{ start: 0, end: 100 }for list/sorted-setqueue types (
waiting,active,delayed). Both RedisLRANGEandZRANGEuse inclusive bounds, so this call:returns 101 elements (indices 0 through 100 inclusive), not 100.
This is inconsistent with the
size: 100default used for the set-basedqueue types (
failed,succeeded), where the intent is clearly to returnat most 100 jobs by default.
Fix
Change the default
endfrom100to99so that a no-argumentgetJobs('waiting')call returns at most 100 jobs, matching the behaviourof
getJobs('failed')and the documented intent.Callers who pass an explicit
page.endare unaffected.