Skip to content

Comments

Update the public ChannelMetadata viewset to support token filter#5715

Open
taoerman wants to merge 3 commits intolearningequality:unstablefrom
taoerman:issue-5462-Update-the-public-ChannelMetadata-viewset-to-support-token-filter
Open

Update the public ChannelMetadata viewset to support token filter#5715
taoerman wants to merge 3 commits intolearningequality:unstablefrom
taoerman:issue-5462-Update-the-public-ChannelMetadata-viewset-to-support-token-filter

Conversation

@taoerman
Copy link
Member

Summary

Implements token-based filtering for the ChannelMetadataViewSet (v2 public API). Previously, token-based channel lookup was only available through the v1 endpoint (get_public_channel_lookup). This change brings that functionality to the v2 API with support for both Channel tokens and ChannelVersion tokens.

  • The ChannelMetadataViewSet now has support for token filtering
  • Returns adequate values for channel tokens
  • Returns adequate values for channel version tokens (with version-specific published_size)
  • New unit tests added to ensure token filtering works correctly
  • New unit tests verify other filters keep working when no token is provided

References

Fixed #5462

Reviewer guidance

Run Unit Tests


if channels.exists():
channel_ids = list(channels.values_list("id", flat=True))
return models.ChannelMetadata.objects.filter(id__in=channel_ids), None
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @taoerman! It seems there has been a misunderstanding here, for this spec:

We'll need to create a get_queryset_from_token method. This method will receive a token and will build the channel queryset, fetching the Channels with the token matching one of its secret tokens, and ChannelVersions 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.

We should get the data from the contentcuration models, because the channels we will import using tokens are private, not public, this is why we can't retrieve them from the public models like this return models.ChannelMetadata.objects.filter(id__in=channel_ids), we will need to get the data from the private models, and annotate/adapt the fields that are different/missing on the public models. As a result, we should get an annotated queryset that complies with the api that we are exposing in the viewset values field

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update the public ChannelMetadata viewset to support token filter

2 participants