queues: Add an index on PlaylistSong.state

This commit is contained in:
Daan Sprenkels
2018-04-09 17:45:47 +02:00
parent 126372a758
commit 7daacc50bb
2 changed files with 19 additions and 1 deletions

View File

@ -0,0 +1,18 @@
# Generated by Django 2.0.4 on 2018-04-09 15:44
from django.db import migrations, models
class Migration(migrations.Migration):
dependencies = [
('queues', '0005_playlistsong_played_at'),
]
operations = [
migrations.AlterField(
model_name='playlistsong',
name='state',
field=models.IntegerField(db_index=True, default=0),
),
]

View File

@ -35,7 +35,7 @@ class PlaylistSong(models.Model):
# 1: Playing. # 1: Playing.
# 2: Played. # 2: Played.
# 3: Cancelled. # 3: Cancelled.
state = models.IntegerField(default=0) state = models.IntegerField(default=0, db_index=True)
def move_up(self): def move_up(self):
other_song = PlaylistSong.objects.filter(playlist=self.playlist, id__lt=self.id)\ other_song = PlaylistSong.objects.filter(playlist=self.playlist, id__lt=self.id)\