Skip to content

Commit

Permalink
Merge pull request #53 from Koed00/dev
Browse files Browse the repository at this point in the history
Fixes backward compatibility problems with django-picklefield
  • Loading branch information
Koed00 committed Sep 7, 2015
2 parents eff51cf + 2078080 commit b5c118b
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
2 changes: 1 addition & 1 deletion django_q/__init__.py
Expand Up @@ -9,6 +9,6 @@
from .cluster import Cluster
from .status import Stat

VERSION = (0, 6, 1)
VERSION = (0, 6, 2)

default_app_config = 'django_q.apps.DjangoQConfig'
14 changes: 12 additions & 2 deletions django_q/models.py
@@ -1,4 +1,5 @@
import logging
from django import get_version

import importlib
from django.core.urlresolvers import reverse
Expand Down Expand Up @@ -33,12 +34,11 @@ def get_result(task_id):

@staticmethod
def get_result_group(group_id, failures=False):
# values + decode is 10 times faster than just list comprehension
if failures:
values = Task.objects.filter(group=group_id).values_list('result', flat=True)
else:
values = Task.objects.filter(group=group_id).exclude(success=False).values_list('result', flat=True)
return [dbsafe_decode(t) for t in values]
return decode_results(values)

@staticmethod
def get_group_count(group_id, failures=False):
Expand Down Expand Up @@ -186,3 +186,13 @@ class Meta:
verbose_name = _('Scheduled task')
verbose_name_plural = _('Scheduled tasks')
ordering = ['next_run']


# Backwards compatibility for Django 1.7
def decode_results(values):
if get_version().split('.')[1] == '7':
# decode values in 1.7
return [dbsafe_decode(v) for v in values]
return values


4 changes: 2 additions & 2 deletions django_q/tests/test_cluster.py
Expand Up @@ -209,8 +209,8 @@ def test_async(broker, admin_user):
assert fetch(result_j.name) == result_j
assert result(result_j.name) == result_j.result
# groups
assert result_group('test_j') == [result_j.result]
assert result_group('test_j', failures=True) == [result_j.result]
assert result_group('test_j')[0] == result_j.result
assert result_group('test_j', failures=True)[0] == result_j.result
assert fetch_group('test_j')[0].id == [result_j][0].id
assert fetch_group('test_j', failures=False)[0].id == [result_j][0].id
assert count_group('test_j') == 1
Expand Down
2 changes: 1 addition & 1 deletion docs/conf.py
Expand Up @@ -72,7 +72,7 @@
# The short X.Y version.
version = '0.6'
# The full version, including alpha/beta/rc tags.
release = '0.6.1'
release = '0.6.2'

# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Expand Up @@ -6,7 +6,7 @@
#
arrow==0.6.0
blessed==1.9.5
django-picklefield==0.3.1
django-picklefield==0.3.2
django-redis==4.2.0
future==0.15.0
hiredis==0.2.0
Expand Down
4 changes: 2 additions & 2 deletions setup.py
Expand Up @@ -26,7 +26,7 @@ def run(self):

setup(
name='django-q',
version='0.6.1',
version='0.6.2',
author='Ilan Steemers',
author_email='koed00@gmail.com',
keywords='django task queue worker redis disque multiprocessing',
Expand All @@ -36,7 +36,7 @@ def run(self):
license='MIT',
description='A multiprocessing task queue for Django',
long_description=README,
install_requires=['django>=1.7', 'django-picklefield===0.3.1', 'blessed', 'arrow', 'future'],
install_requires=['django>=1.7', 'django-picklefield', 'blessed', 'arrow', 'future'],
test_requires=['pytest', 'pytest-django', ],
cmdclass={'test': PyTest},
classifiers=[
Expand Down

0 comments on commit b5c118b

Please sign in to comment.