agendas: add an index on Event (#77590)
This commit is contained in:
parent
11559acd35
commit
31f4e5c059
|
@ -0,0 +1,21 @@
|
||||||
|
import django.db.models.expressions
|
||||||
|
import django.db.models.functions.datetime
|
||||||
|
from django.db import migrations, models
|
||||||
|
|
||||||
|
|
||||||
|
class Migration(migrations.Migration):
|
||||||
|
dependencies = [
|
||||||
|
('agendas', '0152_auto_20230331_0834'),
|
||||||
|
]
|
||||||
|
|
||||||
|
operations = [
|
||||||
|
migrations.AddIndex(
|
||||||
|
model_name='event',
|
||||||
|
index=models.Index(
|
||||||
|
django.db.models.functions.datetime.ExtractWeekDay('start_datetime'),
|
||||||
|
django.db.models.expressions.F('start_datetime'),
|
||||||
|
condition=models.Q(('cancelled', False)),
|
||||||
|
name='start_datetime_dow_index',
|
||||||
|
),
|
||||||
|
),
|
||||||
|
]
|
|
@ -1536,6 +1536,14 @@ class Event(models.Model):
|
||||||
class Meta:
|
class Meta:
|
||||||
ordering = ['agenda', 'start_datetime', 'duration', 'label']
|
ordering = ['agenda', 'start_datetime', 'duration', 'label']
|
||||||
unique_together = ('agenda', 'slug')
|
unique_together = ('agenda', 'slug')
|
||||||
|
indexes = [
|
||||||
|
models.Index(
|
||||||
|
ExtractWeekDay('start_datetime'),
|
||||||
|
'start_datetime',
|
||||||
|
name='start_datetime_dow_index',
|
||||||
|
condition=models.Q(cancelled=False),
|
||||||
|
)
|
||||||
|
]
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
if self.label:
|
if self.label:
|
||||||
|
|
Loading…
Reference in New Issue