Skip to content

Commit

Permalink
perf: add index to is_blacklisted and created field for performance i…
Browse files Browse the repository at this point in the history
…mprovements for xblocks api
  • Loading branch information
AfaqShuaib09 committed Aug 22, 2024
1 parent e28f82a commit e39f83c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
1 change: 0 additions & 1 deletion taxonomy/api/v1/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,6 @@ class XBlockSkillsViewSet(TaxonomyAPIViewSetMixin, RetrieveModelMixin, ListModel
If skill validation is disabled for a course, then return an empty queryset.
"""
serializer_class = XBlocksSkillsSerializer
permission_classes = (permissions.IsAuthenticated, )
filter_backends = (DjangoFilterBackend,)
filterset_class = XBlocksFilter

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Generated by Django 4.2.14 on 2024-08-22 09:43

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('taxonomy', '0036_auto_20240325_1631'),
]

operations = [
migrations.AlterField(
model_name='xblockskilldata',
name='is_blacklisted',
field=models.BooleanField(db_index=True, default=False, help_text='Blacklist this xblock skill, useful to handle false positives.'),
),
migrations.AddIndex(
model_name='xblockskilldata',
index=models.Index(fields=['created'], name='taxonomy_xb_created_5929ec_idx'),
),
]
5 changes: 4 additions & 1 deletion taxonomy/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ class XBlockSkillData(TimeStampedModel):
)
is_blacklisted = models.BooleanField(
help_text=_('Blacklist this xblock skill, useful to handle false positives.'),
default=False,
default=False, db_index=True
)

class Meta:
Expand All @@ -251,6 +251,9 @@ class Meta:
ordering = ('created', )
app_label = 'taxonomy'
unique_together = ('xblock', 'skill')
indexes = [
models.Index(fields=['created']),
]

def __str__(self):
"""
Expand Down

0 comments on commit e39f83c

Please sign in to comment.