Skip to content

Commit

Permalink
Fix result in job detail (#639)
Browse files Browse the repository at this point in the history
* Bump version to 2.10

* Bump version to 2.10.1

* Fixed a typo in job_detail.html
  • Loading branch information
selwin authored Dec 26, 2023
1 parent 45b7023 commit 5da4d66
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 22 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
### Version 2.10.1 (2023-12-18)
* Fixed packaging issues with 2.10.0.

### Version 2.10.0 (2023-12-18)
* Added `rqworker-pool` management command. Thanks @chromium7!
* Compatibility with Django 5.0. Thanks @perry!
* The scheduler now defaults to db 0. Thanks @bennylope!

### Version 2.9.0 (2023-11-26)
* Added an option to delete all failed jobs. Thanks @chromium7!
* You can now specify `SERIALIZER` option while declaring queues in `settings.py` Thanks @sophcass!
Expand Down
24 changes: 6 additions & 18 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,11 @@ with the path to your queue class::

To use a custom job class, provide ``--job-class`` flag.

Support for scheduled jobs
Starting from version 2.10, running RQ's worker-pool is also supported::

python manage.py rqworker-pool default low medium --num-workers 4

Support for Scheduled Jobs
--------------------------

With RQ 1.2.0. you can use `built-in scheduler <https://python-rq.org/docs/scheduling/>`__
Expand Down Expand Up @@ -338,7 +342,7 @@ Additionally, these statistics are also accessible from the command line.

Configuring Sentry
-------------------
Django-RQ >= 2.0 uses ``sentry-sdk`` instead of the deprecated ``raven`` library. Sentry
Sentry
should be configured within the Django ``settings.py`` as described in the `Sentry docs <https://docs.sentry.io/platforms/python/django/>`__.

You can override the default Django Sentry configuration when running the ``rqworker`` command
Expand Down Expand Up @@ -382,11 +386,6 @@ RQ uses Python's ``logging``, this means you can easily configure ``rqworker``'s
"formatter": "rq_console",
"exclude": ["%(asctime)s"],
},
# If you use sentry for logging
'sentry': {
'level': 'ERROR',
'class': 'raven.contrib.django.handlers.SentryHandler',
},
},
'loggers': {
"rq.worker": {
Expand All @@ -396,17 +395,6 @@ RQ uses Python's ``logging``, this means you can easily configure ``rqworker``'s
}
}
Note: error logging to Sentry is known to be unreliable with RQ when using async
transports (the default transport). Please configure ``Raven`` to use
``sync+https://`` or ``requests+https://`` transport in ``settings.py``:

.. code-block:: python
RAVEN_CONFIG = {
'dsn': 'sync+https://public:[email protected]/1',
}
For more info, refer to `Raven's documentation <http://raven.readthedocs.org/>`__.
Custom Queue Classes
--------------------
Expand Down
2 changes: 1 addition & 1 deletion django_rq/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
VERSION = (2, 9, 0)
VERSION = (2, 10, 1)

from .decorators import job
from .queues import enqueue, get_connection, get_queue, get_scheduler
Expand Down
2 changes: 1 addition & 1 deletion django_rq/templates/django_rq/job_detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ <h2>Result {{ result.id }}</h2>

<div class="form-row field-votes">
<div>
<label>Created at: {{ result.Type }}</label>
<label>Created at:</label>
<div class="readonly">{{ result.created_at|to_localtime|date:"Y-m-d, H:i:s" }}</div>
</div>
</div>
Expand Down
12 changes: 12 additions & 0 deletions django_rq/tests/test_views.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,18 @@ def test_job_details(self):
response = self.client.get(url)
self.assertEqual(response.status_code, 200)
self.assertIn('DeserializationError', response.content.decode())

def test_job_details_with_results(self):
"""Job with results is displayed properly"""
queue = get_queue('default')
job = queue.enqueue(access_self)
queue_index = get_queue_index('default')
worker = get_worker('default')
worker.work(burst=True)
result = job.results()[0]
url = reverse('rq_job_detail', args=[queue_index, job.id])
response = self.client.get(url)
self.assertContains(response, result.id)

def test_job_details_on_deleted_dependency(self):
"""Page doesn't crash even if job.dependency has been deleted"""
Expand Down
5 changes: 4 additions & 1 deletion django_rq/tests/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,10 @@ def get_queue_index(name='default'):
connection = get_connection(name)
connection_kwargs = connection.connection_pool.connection_kwargs
for i in range(0, 100):
q = get_queue_by_index(i)
try:
q = get_queue_by_index(i)
except AttributeError:
continue
if q.name == name and q.connection.connection_pool.connection_kwargs == connection_kwargs:
queue_index = i
break
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

setup(
name='django-rq',
version='2.9.0',
version='2.10.1',
author='Selwin Ong',
author_email='[email protected]',
packages=['django_rq'],
Expand Down

0 comments on commit 5da4d66

Please sign in to comment.