From 5cfbae61a9dc28b1fe330e8b0c7158dda96bbaf0 Mon Sep 17 00:00:00 2001 From: oniltonmaciel Date: Sun, 16 Jun 2013 17:38:25 -0400 Subject: [PATCH 1/3] Replaced limit by length and start by offset Replaced limit by length and start by offset to remove a possible ambiguity --- rq/queue.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/rq/queue.py b/rq/queue.py index a7a82bc..a418a4e 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -74,17 +74,17 @@ class Queue(object): return None return job - def get_job_ids(self, start=0, limit=-1): + def get_job_ids(self, offset=0, length=-1): """Returns a slice of job IDs in the queue.""" - if limit >= 0: - end = start + limit + if length >= 0: + end = start + length else: - end = limit + end = lenth return self.connection.lrange(self.key, start, end) - def get_jobs(self, start=0, limit=-1): + def get_jobs(self, offset=0, length=-1): """Returns a slice of jobs in the queue.""" - job_ids = self.get_job_ids(start, limit) + job_ids = self.get_job_ids(start, length) return compact([self.safe_fetch_job(job_id) for job_id in job_ids]) @property From 97de8ea3ccc122e06a8871f7e281db790379e13f Mon Sep 17 00:00:00 2001 From: Onilton Maciel Date: Sun, 16 Jun 2013 17:45:04 -0400 Subject: [PATCH 2/3] Fixed typos and errors found. Tests passing now --- rq/queue.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rq/queue.py b/rq/queue.py index a418a4e..759c485 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -76,15 +76,16 @@ class Queue(object): def get_job_ids(self, offset=0, length=-1): """Returns a slice of job IDs in the queue.""" + start = offset if length >= 0: - end = start + length + end = offset + length else: - end = lenth + end = length return self.connection.lrange(self.key, start, end) def get_jobs(self, offset=0, length=-1): """Returns a slice of jobs in the queue.""" - job_ids = self.get_job_ids(start, length) + job_ids = self.get_job_ids(offset, length) return compact([self.safe_fetch_job(job_id) for job_id in job_ids]) @property From 3afc32f08ab4b73dfd937870e73073d756711b5c Mon Sep 17 00:00:00 2001 From: Onilton Maciel Date: Sun, 16 Jun 2013 18:11:03 -0400 Subject: [PATCH 3/3] End calculation in get_jobs_ids in fixed. Length is respected --- rq/queue.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rq/queue.py b/rq/queue.py index 759c485..d08311c 100644 --- a/rq/queue.py +++ b/rq/queue.py @@ -78,7 +78,7 @@ class Queue(object): """Returns a slice of job IDs in the queue.""" start = offset if length >= 0: - end = offset + length + end = offset + (length - 1) else: end = length return self.connection.lrange(self.key, start, end)