Skip to content

Commit

Permalink
improve article indexing
Browse files Browse the repository at this point in the history
  • Loading branch information
keeganland committed May 7, 2021
1 parent 066a5e0 commit 2585d5d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 0 deletions.
25 changes: 25 additions & 0 deletions dispatch/migrations/0104_auto_20210507_1203.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Generated by Django 3.1.8 on 2021-05-07 19:03

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('dispatch', '0103_auto_20210505_0050'),
]

operations = [
migrations.AddIndex(
model_name='article',
index=models.Index(fields=['-published_at'], name='dispatch_ar_publish_cc3607_idx'),
),
migrations.AddIndex(
model_name='article',
index=models.Index(fields=['head', 'is_published'], name='dispatch_ar_head_faebef_idx'),
),
migrations.AddIndex(
model_name='article',
index=models.Index(fields=['section'], name='dispatch_ar_section_6fccdb_idx'),
),
]
9 changes: 9 additions & 0 deletions dispatch/modules/content/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import uuid
import datetime

from django.db import models

from sys import getsizeof
from jsonfield import JSONField
from PIL import Image as Img
Expand Down Expand Up @@ -413,6 +415,13 @@ def save_subsection(self, subsection_id):
""" Save the subsection to the parent article """
Article.objects.filter(parent_id=self.parent.id).update(subsection_id=subsection_id)

class Meta:
indexes = [
models.Index(fields=['-published_at']),
models.Index(fields=['head', 'is_published']),
models.Index(fields=['section']),
]

class Subsection(Model, AuthorMixin):
name = CharField(max_length=100, unique=True)
slug = SlugField(unique=True)
Expand Down

0 comments on commit 2585d5d

Please sign in to comment.