From a863dfc1806a7cf6efd38b68504fba73d7e1dfe7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Stefan=20K=C3=B6gl?= Date: Mon, 25 Aug 2014 16:07:36 +0000 Subject: [PATCH] [DB] add indexes for episodes, slugs --- mygpo/podcasts/migrations/0025_episode_index.py | 18 ++++++++++++++++++ mygpo/podcasts/migrations/0026_slug_index.py | 18 ++++++++++++++++++ mygpo/podcasts/migrations/0027_episode_index.py | 18 ++++++++++++++++++ mygpo/podcasts/models.py | 10 ++++++++++ 4 files changed, 64 insertions(+) create mode 100644 mygpo/podcasts/migrations/0025_episode_index.py create mode 100644 mygpo/podcasts/migrations/0026_slug_index.py create mode 100644 mygpo/podcasts/migrations/0027_episode_index.py diff --git a/mygpo/podcasts/migrations/0025_episode_index.py b/mygpo/podcasts/migrations/0025_episode_index.py new file mode 100644 index 00000000..055b6af3 --- /dev/null +++ b/mygpo/podcasts/migrations/0025_episode_index.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('podcasts', '0024_episodes_index'), + ] + + operations = [ + migrations.AlterIndexTogether( + name='episode', + index_together=set([('podcast', 'outdated', 'released')]), + ), + ] diff --git a/mygpo/podcasts/migrations/0026_slug_index.py b/mygpo/podcasts/migrations/0026_slug_index.py new file mode 100644 index 00000000..99b7ada6 --- /dev/null +++ b/mygpo/podcasts/migrations/0026_slug_index.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('podcasts', '0025_episode_index'), + ] + + operations = [ + migrations.AlterIndexTogether( + name='slug', + index_together=set([('slug', 'content_type')]), + ), + ] diff --git a/mygpo/podcasts/migrations/0027_episode_index.py b/mygpo/podcasts/migrations/0027_episode_index.py new file mode 100644 index 00000000..78f80b70 --- /dev/null +++ b/mygpo/podcasts/migrations/0027_episode_index.py @@ -0,0 +1,18 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('podcasts', '0026_slug_index'), + ] + + operations = [ + migrations.AlterIndexTogether( + name='episode', + index_together=set([('podcast', 'released'), ('podcast', 'outdated', 'released')]), + ), + ] diff --git a/mygpo/podcasts/models.py b/mygpo/podcasts/models.py index 9639b6b6..b7741ab3 100644 --- a/mygpo/podcasts/models.py +++ b/mygpo/podcasts/models.py @@ -593,6 +593,12 @@ class Episode(UUIDModel, TitleModel, DescriptionModel, LinkModel, class Meta: ordering = ['-released'] + index_together = [ + ('podcast', 'outdated', 'released'), + ('podcast', 'released'), + ('released', 'podcast'), + ] + @property def scope(self): """ An episode's scope is its podcast """ @@ -734,6 +740,10 @@ class Slug(OrderedModel, ScopedModel): ('content_type', 'object_id', 'order'), ) + index_together = [ + ('slug', 'content_type') + ] + def __repr__(self): return '{cls}(slug={slug}, order={order}, content_object={obj}'.format( cls=self.__class__.__name__, -- 2.11.4.GIT