-
Notifications
You must be signed in to change notification settings - Fork 299
Closed
Copy link
Labels
P0 - criticalPriority: Release blocker or regressionPriority: Release blocker or regression
Description
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Requires #5171
Overview
In #5171, we introduced a categories JSON field within the ChannelMetadata model. However, JSON fields are not optimal for efficient filtering by categories. Therefore, as part of addressing this issue, we will implement bitmask fields to enable performant category lookups.
Prerrequisites
- Explore how the bitmask_fieldnames are added and annotated to the
kolibri_publicContentNode model. - Explore how bitmask filters works in the
kolibri_publicContentNode viewset .
Technical requirements
- We will need to add
categoriesbitmask fields to theChannelMetadatamodel in the kolibri_public models file. Similar to what we do for theContentNodemodel here, but instead of adding bitmask for all thesemetadata_lookupfields, we will be just adding the ones for theCategoriesfield. Therefore, we should find a way to obtain these bitmask fields for a subset of the available metadata_lookup fields, and add them to theChannelMetadatamodel. - We should update the annotate_label_bitmasks method to support annotating just a subset of fields that are in the
metadata_lookup, so we can annotate just the bitmask of thecategoriesof the ChannelMetadata model's queryset. - Next, in the set_channel_metadata_fields, we can call the
annotate_label_bitmasksto annotate the bitmasks of thecategoriesfield of the given channel.- For context, this method is called within the
ChannelMapper'srunmethod, and the idea is that here we also annotate the bitmasks fields of the channel being mapped.
- For context, this method is called within the
- Then, to allow filtering channels by categories, we will need to move this has_all_labels method to the search module, and make it generic for any given
queryset(i.e., make this function receive the queryset, field_name, and labels as arguments). Then refactor theContentNodeQueryset'has_all_labelsmethod to use this new function. - Then, create a new
ChannelMetadataQuerysetclass that contains thishas_all_labelsmethod and apply it to a newChannelMetadataManagerclass that will be then used in the ChannelMetadata public model. - And finally, add a new
categoriesfilter to the ChannelMetadata filterset similar to the bitmasks filters we have for the ContentNode filterset. - Additionally, we can create at least the following tests:
- New tests in the ChannelMapper test case to test that the
categoriesbitmasks have been correctly set for the channel. - Create a new test file in the kolibri_public tests folder to test the new
categoriesfilter of theChannelMetadataViewSet.
- New tests in the ChannelMapper test case to test that the
Acceptance criteria
- New
categoriesbitmasks fields are added to the ChannelMetadata public model. - The
categoriesbitmasks fields are correctly annotated when a channel is mapped to thekolibri_publicmodels. - We can now filter the
ChannelMetadataViewSetbycategories. - Described unit tests have been added.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P0 - criticalPriority: Release blocker or regressionPriority: Release blocker or regression
