Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove channel labels from non-public ContentNode API #12843

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

Pulkitxm
Copy link

Fixes

Closes #12842

Summary

  • Removed the channel labels from the non-public ContentNodeViewset API.
  • Added a flag use_deprecated_channels_labels to the OptionalContentNodePagination class to handle the inclusion of channel labels.
  • Ensured that the public API still provides the channel labels.
  • Verified that older Kolibri versions can navigate and search the library remotely without issues.

References

  • Issue: Remove the channel labels from the non-public ContentNode API
  • Related PR: Update SearchFiltersPanel for Coach

Reviewer guidance

  • Test the non-public ContentNodeViewset API to ensure that channel labels are no longer returned.
  • Verify that the public API still provides the channel labels.
  • Ensure that older Kolibri versions (0.17.x) can navigate and search the library remotely from Kolibri 0.18.x and filter by Channels.
  • Check for any potential issues or regressions in the search functionality and filtering by channels.

Testing checklist

  • Contributor has fully tested the PR manually
  • If there are any front-end changes, before/after screenshots are included
  • Critical user journeys are covered by Gherkin stories
  • Critical and brittle code paths are covered by unit tests

PR process

  • PR has the correct target branch and milestone
  • PR has 'needs review' or 'work-in-progress' label
  • If PR is ready for review, a reviewer has been added. (Don't use 'Assignees')
  • If this is an important user-facing change, PR or related issue has a 'changelog' label
  • If this includes an internal dependency change, a link to the diff is provided

Reviewer checklist

  • PR is fully functional
  • PR has been tested for accessibility regressions
  • External dependency files were updated if necessary (yarn and pip)
  • Documentation is updated
  • Contributor is in AUTHORS.md

@github-actions github-actions bot added the DEV: backend Python, databases, networking, filesystem... label Nov 14, 2024
@MisRob
Copy link
Member

MisRob commented Nov 14, 2024

Hi @Pulkitxm, welcome and thanks for your effort.

@nucleogenesis would you please have a look and decide whether we should review and if so, if the changes make sense?

@Pulkitxm Looking at #12842 it wasn't originally indicated as open for contributions. I wanted to provide some guidance so next time you can contribute successfully. Please find an unassigned 'help wanted' issue and before working on it, message us there and wait for an assignment. It's best to familiarize yourself with the contributing guidelines:

Then you can see the list of unassigned "help wanted" or "good first issue" issues across all repositories.

@MisRob MisRob requested a review from nucleogenesis November 14, 2024 07:40
Copy link
Member

@rtibbles rtibbles left a comment

Choose a reason for hiding this comment

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

This needs some cleaning up - this may achieve the end desired end result, but has more code changes than I would expect, and adds additional code changes that are not needed.

This rather has the appearance of having been automatically generated by a generative AI, due to these extra, seemingly duplicative, changes. Feel free to use AI, however make sure you can understand the task and adjust the AI output in a meaningful manner, and provide with the smallest diff needed to achieve the task at hand.

@@ -828,39 +828,56 @@ class OptionalContentNodePagination(OptionalPagination):
def paginate_queryset(self, queryset, request, view=None):
# Record the queryset for use in returning available filters
self.queryset = queryset
self.use_deprecated_channels_labels = (
request.query_params.get("use_deprecated_channels_labels", "false").lower()
Copy link
Member

Choose a reason for hiding this comment

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

Using a query parameter to set this was not asked for in the issue description - this should be removed.

return super(OptionalContentNodePagination, self).paginate_queryset(
queryset, request, view=view
)

def get_paginated_response(self, data):
labels = get_available_metadata_labels(self.queryset)
Copy link
Member

Choose a reason for hiding this comment

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

I think it would be cleaner to pass through this flag into the get_available_metadata_labels function and have that do the conditional behaviour for adding it to the labels.

return Response(
OrderedDict(
[
("more", self.get_more()),
("results", data),
("labels", get_available_metadata_labels(self.queryset)),
Copy link
Member

Choose a reason for hiding this comment

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

This can remain inline with just the new argument for deprecated channel labels being passed.

]
)
)

def get_paginated_response_schema(self, schema):
return {
Copy link
Member

Choose a reason for hiding this comment

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

No need to update this at all.

@@ -950,6 +967,18 @@ def recommendations_for(self, request, **kwargs):
)
return Response(self.serialize(queryset))

def get_paginated_response(self, data):
Copy link
Member

Choose a reason for hiding this comment

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

This method doesn't belong on this class - this is extraneous.

}

class DeprecatedChannelsLabelsPagination(OptionalContentNodePagination):
def paginate_queryset(self, queryset, request, view=None):
Copy link
Member

Choose a reason for hiding this comment

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

Instead of having to set this inside the paginate_queryset call, you can instead just define it as a class property:

class DeprecatedChannelsLabelsPagination(OptionalContentNodePagination):
    use_deprecated_channels_labels = True

@@ -77,14 +77,22 @@ def _get_available_languages(base_queryset):
return list(langs)


def _get_available_channels(base_queryset):
def _get_available_channels(base_queryset, include_labels=False):
Copy link
Member

@rtibbles rtibbles Nov 14, 2024

Choose a reason for hiding this comment

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

This method doesn't need to be updated, the get_available_metadata_labels method should be updated to conditionally call this and add the result to the returned labels.

@rtibbles rtibbles self-assigned this Nov 19, 2024
@rtibbles
Copy link
Member

Hi @Pulkitxm - any further guidance needed here? Feel free to ask any follow up questions!

Copy link
Member

@nucleogenesis nucleogenesis left a comment

Choose a reason for hiding this comment

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

@Pulkitxm do you think you'll be able to address the feedback given above? If so please let us know, even if you need some additional time, otherwise we'll probably close this PR and reassign the related issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
DEV: backend Python, databases, networking, filesystem...
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove the channel labels from the non-public ContentNode API
4 participants