Skip to content

Commit

Permalink
Show job ended_at (#557)
Browse files Browse the repository at this point in the history
* First stab at setting up Github actions

* Use Redis Github Action

* Set working directory

* Fixed some tests

* Fixed tests

* Test with more django versions

* Only test with Python >= 3.8

* Use the most recent version of django-redis

* Fixed test warnings

* add runtime statistics and ended_at field to jobs.html

Co-authored-by: pengxiaotao <[email protected]>
  • Loading branch information
selwin and pengxiaotao authored Nov 5, 2022
1 parent 5d2a12b commit d9b8ec1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 14 deletions.
6 changes: 6 additions & 0 deletions django_rq/templates/django_rq/jobs.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<th><div class = 'text'><span>Scheduled</span></div></th>
{% endif %}
<th><div class = 'text'><span>Enqueued</span></div></th>
<th><div class = 'text'><span>Ended</span></div></th>
<th><div class = 'text'><span>Status</span></div></th>
<th><div class = 'text'><span>Callable</span></div></th>
{% block extra_columns %}
Expand Down Expand Up @@ -108,6 +109,11 @@
{{ job.enqueued_at|to_localtime|date:"Y-m-d, H:i:s" }}
{% endif %}
</td>
<td>
{% if job.ended_at %}
{{ job.ended_at|to_localtime|date:"Y-m-d, H:i:s" }}
{% endif %}
</td>
<td>{{ job.get_status }}</td>
<td>{{ job|show_func_name }}</td>
{% block extra_columns_values %}
Expand Down
4 changes: 4 additions & 0 deletions django_rq/tests/fixtures.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ class DummyScheduler(Scheduler):

def access_self():
return get_current_job().id


def failing_job():
raise ValueError
16 changes: 2 additions & 14 deletions django_rq/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

from django_rq import get_queue
from django_rq.workers import get_worker
from .fixtures import access_self
from .fixtures import access_self, failing_job
from .utils import get_queue_index


Expand Down Expand Up @@ -75,9 +75,6 @@ def test_requeue_job(self):
"""
Ensure that a failed job gets requeued when rq_requeue_job is called
"""
def failing_job():
raise ValueError

queue = get_queue('default')
queue_index = get_queue_index('default')
job = queue.enqueue(failing_job)
Expand All @@ -94,12 +91,9 @@ def test_requeue_all(self):
"""
Ensure that requeuing all failed job work properly
"""
def failing_job():
raise ValueError

queue = get_queue('default')
queue_index = get_queue_index('default')
job = queue.enqueue(failing_job)
queue.enqueue(failing_job)
queue.enqueue(failing_job)
worker = get_worker('default')
worker.work(burst=True)
Expand All @@ -114,9 +108,6 @@ def test_requeue_all_if_deleted_job(self):
"""
Ensure that requeuing all failed job work properly
"""
def failing_job():
raise ValueError

queue = get_queue('default')
queue_index = get_queue_index('default')
job = queue.enqueue(failing_job)
Expand Down Expand Up @@ -188,9 +179,6 @@ def test_enqueue_jobs(self):
self.assertIsNotNone(last_job.enqueued_at)

def test_action_requeue_jobs(self):
def failing_job():
raise ValueError

queue = get_queue('django_rq_test')
queue_index = get_queue_index('django_rq_test')

Expand Down

0 comments on commit d9b8ec1

Please sign in to comment.