mirror of
https://github.com/django-q2/django-q2.git
synced 2026-10-05 01:48:12 +08:00
decoding values_list on a picklefield turns out to be 10 times faster than using list_comprehension
This commit is contained in:
+4
-2
@@ -8,6 +8,7 @@ from django.db.models.signals import pre_save
|
|||||||
from django.dispatch import receiver
|
from django.dispatch import receiver
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
from picklefield import PickledObjectField
|
from picklefield import PickledObjectField
|
||||||
|
from picklefield.fields import dbsafe_decode
|
||||||
|
|
||||||
|
|
||||||
class Task(models.Model):
|
class Task(models.Model):
|
||||||
@@ -32,8 +33,9 @@ class Task(models.Model):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_result_group(group_id):
|
def get_result_group(group_id):
|
||||||
# values_list() doesn't work here cause it returns encoded fields
|
# values + decode is 10 times faster than just list comprehension
|
||||||
return [t.result for t in Task.get_task_group(group_id)]
|
values = Task.objects.filter(group=group_id).values_list('result', flat=True)
|
||||||
|
return [dbsafe_decode(t) for t in values]
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def get_task(task_id):
|
def get_task(task_id):
|
||||||
|
|||||||
Reference in New Issue
Block a user