added indexes to support objects.filter and .order searches

dj111py38
Mark Jenkins 2016-01-19 07:06:42 -06:00
parent c7add25900
commit 2615e4e1dd
7 changed files with 129 additions and 0 deletions

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('questionnaire', '0010_index_choice_value'),
]
operations = [
migrations.AlterIndexTogether(
name='question',
index_together=set([('number', 'questionset')]),
),
]

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('questionnaire', '0011_index_on_question_mod_number_questionset'),
]
operations = [
migrations.AlterIndexTogether(
name='questionset',
index_together=set([('questionnaire', 'sortid')]),
),
]

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('questionnaire', '0012_questionset_questionnaire_and_sortid_index'),
]
operations = [
migrations.AlterIndexTogether(
name='answer',
index_together=set([('subject', 'runid', 'id'), ('subject', 'runid')]),
),
]

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('questionnaire', '0013__answer_index_subject_run_id'),
]
operations = [
migrations.AlterIndexTogether(
name='runinfo',
index_together=set([('random',)]),
),
]

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('questionnaire', '0014__runinfo_index_random'),
]
operations = [
migrations.AlterIndexTogether(
name='questionset',
index_together=set([('questionnaire', 'sortid'), ('sortid',)]),
),
]

View File

@ -0,0 +1,18 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('questionnaire', '0015_questionnaire_index_sortid'),
]
operations = [
migrations.AlterIndexTogether(
name='subject',
index_together=set([('givenname', 'surname')]),
),
]

View File

@ -63,6 +63,11 @@ class Subject(models.Model):
def pending(self):
return RunInfo.objects.filter(subject=self).order_by('runid')
class Meta:
index_together = [
["givenname", "surname"],
]
class GlobalStyles(models.Model):
content = models.TextField()
@ -171,6 +176,10 @@ class QuestionSet(models.Model):
class Meta:
translate = ('text',)
index_together = [
["questionnaire", "sortid"],
["sortid",]
]
class RunInfo(models.Model):
@ -260,6 +269,9 @@ class RunInfo(models.Model):
class Meta:
verbose_name_plural = 'Run Info'
index_together = [
["random"],
]
class RunInfoHistory(models.Model):
@ -407,6 +419,9 @@ class Question(models.Model):
class Meta:
translate = ('text', 'extra', 'footer')
index_together = [
["number", "questionset"],
]
class Choice(models.Model):
@ -482,3 +497,9 @@ class Answer(models.Model):
runinfo.add_tags(tags_to_add)
runinfo.save()
class Meta:
index_together = [
['subject', 'runid'],
['subject', 'runid', 'id'],
]