Skip to content

Commit

Permalink
feat(queue): add getDelayedCount method [python] (#2934)
Browse files Browse the repository at this point in the history
  • Loading branch information
roggervalf authored Nov 26, 2024
1 parent cc6cfc2 commit 71ce75c
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 3 additions & 0 deletions python/bullmq/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,9 @@ def getJobState(self, job_id: str):
def getCompletedCount(self):
return self.getJobCountByTypes('completed')

def getDelayedCount(self):
return self.getJobCountByTypes('delayed')

def getFailedCount(self):
return self.getJobCountByTypes('failed')

Expand Down
14 changes: 13 additions & 1 deletion python/tests/queue_tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async def test_get_job_state(self):
async def test_add_job_with_options(self):
queue = Queue(queueName)
data = {"foo": "bar"}
attempts = 3,
attempts = 3
delay = 1000
job = await queue.add("test-job", data=data, opts={"attempts": attempts, "delay": delay})

Expand Down Expand Up @@ -133,6 +133,18 @@ async def test_trim_events_manually_with_custom_prefix(self):
await queue.obliterate()
await queue.close()

async def test_get_delayed_count(self):
queue = Queue(queueName)
data = {"foo": "bar"}
delay = 1000
await queue.add("test-job", data=data, opts={"delay": delay})
await queue.add("test-job", data=data, opts={"delay": delay * 2})

count = await queue.getDelayedCount()
self.assertEqual(count, 2)

await queue.close()

async def test_retry_failed_jobs(self):
queue = Queue(queueName)
job_count = 8
Expand Down

0 comments on commit 71ce75c

Please sign in to comment.