-
Notifications
You must be signed in to change notification settings - Fork 262
Description
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Overview
After implementing the new ChannelVersion model, we need to expose a way to retrieve specific channel version metadata via the studio public API. The current endpoint that Kolibri uses to retrieve channel metadata using tokens is views_v1.get_public_channel_lookup. However, to introduce the new support for channel version tokens, some tweaks will be needed, and instead of continuing to build on top of the v1 endpoints, we will rather add support for channel tokens on the public channel v2 viewset.
Technical details
The main problem with allowing the public ChannelMetadataViewset to receive a token filter is that, if a token is passed, we need to retrieve these channels from the contentcuration models. That means, we'll need to modify the viewset get_queryset method to return the queryset of token-related channels, but these channels will come from the ContentCuration models. For this:
- We'll need to create a
get_queryset_from_tokenmethod. This method will receive a token and will build the channel queryset, fetching the Channels with the token matching one of its secret tokens, andChannelVersions whose secret token matches the token. Then, we will need to annotate this queryset to fill the missing fields that the Viewset exposes or filters, or that have a different name in the contentcuration models. The idea is that all transformations that we do with the current queryset can be made within the context of this new queryset.- Note that for channel version tokens, fields like the
published_sizeshould match the specific version'spublished_size, not the current channelpublished_size, since it may be different if a new version has been released. - Since, for now, we don't support collections of channels with specific versions, we can assume that if we found channels in the
Channelmodel with a given token, then we can return that queryset without checking the token inChannelVersion.
- Note that for channel version tokens, fields like the
- Check in the get_queryset method if a
tokenquery param is present in the request; if so, return the queryset fromget_queryset_from_token. - For now, if a token is passed, then we will disable all other filters present in the ChannelMetadataFilter. For this, we will override the
filter_querysetmethod to return thequerysetunfiltered if atokenis present in the request query_params. - The consolidate method will also need to be upgraded to
- Skip the
included_languagescomputation for channels fetched via token since they are already computed in theChannelVersionmodel. - Skip the
countriesarray computation since it does not apply to private channels.
- Skip the
Finally, we should update the channel metadata test suites to test that the filter by token is working fine with channel tokens, channel version tokens, and channelset tokens.
Acceptance criteria
- The
ChannelMetadataViewSetnow has support for token filtering. - The
ChannelMetadataViewSetreturns the adequate values for channel and channel version tokens. - New unit tests have been added to ensure that other filters keep working as expected.
