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 23, 2024
1 parent a5b1598 commit af2aeab
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 3 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ Change Log
Unreleased

[1.52.0] - 2024-08-22
---------------------
* perf: Introduced db_index on the `created` and `is_blacklisted` fields in `XBlockSkillData` model
for performance improvements of `xblocks` endpoint

[1.51.1] - 2024-08-21
---------------------
* feat: Added safeguard for nulls before saving job description
Expand Down
2 changes: 1 addition & 1 deletion taxonomy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
# 2. MINOR version when you add functionality in a backwards compatible manner, and
# 3. PATCH version when you make backwards compatible bug fixes.
# More details can be found at https://semver.org/
__version__ = '1.51.1'
__version__ = '1.52.0'

default_app_config = 'taxonomy.apps.TaxonomyConfig' # pylint: disable=invalid-name
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 af2aeab

Please sign in to comment.