Skip to content

Commit c0b82b7

Browse files
fix registry.get_job_id not returning execution id anymore (#700)
This change uses the new ``registry.get_job_and_execution_ids`` instead of the updated ``registry.get_job_id`` which no longer returns the execution id. fixes: #697
1 parent fe539b6 commit c0b82b7

File tree

2 files changed

+15
-8
lines changed

2 files changed

+15
-8
lines changed

django_rq/utils.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import cast, Optional, List, Union
1+
from typing import cast, Optional, List, Tuple, Union
22

33
from django.core.exceptions import ImproperlyConfigured
44
from django.db import connections
@@ -153,13 +153,12 @@ def get_jobs(
153153
return valid_jobs
154154

155155

156-
def get_executions(queue, composite_keys: List[str]) -> List[Execution]:
156+
def get_executions(queue, composite_keys: List[Tuple[str, str]]) -> List[Execution]:
157157
"""Fetch executions in bulk from Redis.
158158
1. If execution data is not present in Redis, discard the result
159159
"""
160160
executions = []
161-
for key in composite_keys:
162-
job_id, id = key.split(':')
161+
for job_id, id in composite_keys:
163162
try:
164163
executions.append(Execution.fetch(id=id, job_id=job_id, connection=queue.connection))
165164
except ValueError:

django_rq/views.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import division
22

33
from math import ceil
4-
from typing import Any
4+
from typing import Any, cast, Tuple
55

66
from django.contrib import admin, messages
77
from django.contrib.admin.views.decorators import staff_member_required
@@ -222,9 +222,17 @@ def started_jobs(request, queue_index):
222222
last_page = int(ceil(num_jobs / items_per_page))
223223
page_range = list(range(1, last_page + 1))
224224
offset = items_per_page * (page - 1)
225-
job_ids = registry.get_job_ids(offset, offset + items_per_page - 1)
226-
jobs = get_jobs(queue, job_ids, registry)
227-
executions = get_executions(queue, job_ids)
225+
226+
try:
227+
composite_keys = registry.get_job_and_execution_ids(offset, offset + items_per_page - 1)
228+
except AttributeError:
229+
composite_keys = [
230+
cast(Tuple[str, str], key.split(':'))
231+
for key in registry.get_job_ids(offset, offset + items_per_page - 1)
232+
]
233+
234+
jobs = get_jobs(queue, [i[0] for i in composite_keys], registry)
235+
executions = get_executions(queue, composite_keys)
228236

229237
else:
230238
page_range = []

0 commit comments

Comments
 (0)