Skip to content

ESoCC: Add bit_mask fields for kolibri_public ChannelMetadata categories #5208

@AlexVelezLl

Description

@AlexVelezLl

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

Technical requirements

  1. We will need to add categories bitmask fields to the ChannelMetadata model in the kolibri_public models file. Similar to what we do for the ContentNode model here, but instead of adding bitmask for all these metadata_lookup fields, we will be just adding the ones for the Categories field. Therefore, we should find a way to obtain these bitmask fields for a subset of the available metadata_lookup fields, and add them to the ChannelMetadata model.
  2. 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 the categories of the ChannelMetadata model's queryset.
  3. Next, in the set_channel_metadata_fields, we can call the annotate_label_bitmasks to annotate the bitmasks of the categories field of the given channel.
    • For context, this method is called within the ChannelMapper 's run method, and the idea is that here we also annotate the bitmasks fields of the channel being mapped.
  4. 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 the ContentNodeQueryset' has_all_labels method to use this new function.
  5. Then, create a new ChannelMetadataQueryset class that contains this has_all_labels method and apply it to a new ChannelMetadataManager class that will be then used in the ChannelMetadata public model.
  6. And finally, add a new categories filter to the ChannelMetadata filterset similar to the bitmasks filters we have for the ContentNode filterset.
  7. Additionally, we can create at least the following tests:

Acceptance criteria

  • New categories bitmasks fields are added to the ChannelMetadata public model.
  • The categories bitmasks fields are correctly annotated when a channel is mapped to the kolibri_public models.
  • We can now filter the ChannelMetadataViewSet by categories.
  • Described unit tests have been added.

Metadata

Metadata

Assignees

Labels

P0 - criticalPriority: Release blocker or regression

Type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions