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

fix: Delete tags_count from LibraryXBlockMetadata [FC-0062] #35510

Conversation

ChrisChV
Copy link
Contributor

@ChrisChV ChrisChV commented Sep 20, 2024

Description

This deletes tags_count from the library block metadata. Currently not used and confusing to have in code

  • Which edX user roles will this change impact? "Course Author",

Supporting information

Testing instructions

Deadline

ASAP

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Sep 20, 2024
@openedx-webhooks
Copy link

openedx-webhooks commented Sep 20, 2024

Thanks for the pull request, @ChrisChV!

What's next?

Please work through the following steps to get your changes ready for engineering review:

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.

🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads

🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.

🔘 Let us know that your PR is ready for review:

Who will review my changes?

This repository is currently maintained by @openedx/wg-maintenance-edx-platform. Tag them in a comment and let them know that your changes are ready for review.

Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

@ChrisChV ChrisChV marked this pull request as draft September 20, 2024 02:06
@ChrisChV ChrisChV marked this pull request as ready for review September 24, 2024 01:59
@ChrisChV ChrisChV changed the title fix: Add tags count to library block metadata fix: Add tags count to library block metadata [FC-0062] Sep 24, 2024
Copy link
Contributor

@rpenido rpenido left a comment

Choose a reason for hiding this comment

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

LGTM 👍
Thank you for your work @ChrisChV!

I left a suggestion about getting the tag count only for the component, instead of the whole library.

Comment on lines 248 to 254
if load_tags_count:
# Build 'lib:' component usage_key from component slug and library_key
component_key = str(component).replace('xblock.v1:', f'{str(library_key)}:').replace('lib:', 'lb:')
components_tags = _get_library_component_tags_count(library_key)

if component_key in components_tags:
tags_count = components_tags[component_key]
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can get the tags only for the block here:

Suggested change
if load_tags_count:
# Build 'lib:' component usage_key from component slug and library_key
component_key = str(component).replace('xblock.v1:', f'{str(library_key)}:').replace('lib:', 'lb:')
components_tags = _get_library_component_tags_count(library_key)
if component_key in components_tags:
tags_count = components_tags[component_key]
if load_tags_count:
from openedx.core.djangoapps.content_tagging.api import get_object_tag_counts
component_tags = get_object_tag_counts(str(component), count_implicit=True)
if component_key in components_tags:
tags_count = components_tags[component_key]

@bradenmacdonald
Copy link
Contributor

bradenmacdonald commented Sep 24, 2024

We don't necessarily need the changes from this PR if you're just wanting the tags count for a single component. You can use the existing API /api/content_tagging/v1/object_tags/:usageKey to get the tags. In fact, we already have a nice hook for it in the Authoring MFE, useContentTaxonomyTagsData(). As long as you make the request in parallel with the "get block metadata" request, it's really not any less efficient. In fact, it's now considered best practice to make several small requests like that at the same time rather than one "big" request, because the "big" request often computes data that isn't needed - like tags_count in this place isn't needed in many places.

Edit: in fact, the tags widget is probably going to be calling that same API anyways, so it's actually more efficient to re-use the same useContentTaxonomyTagsData hook (react-query will de-duplicate the request) rather than adding an additional query to the metadata API.

@ChrisChV
Copy link
Contributor Author

We don't necessarily need the changes from this PR if you're just wanting the tags count for a single component. You can use the existing API /api/content_tagging/v1/object_tags/:usageKey to get the tags. In fact, we already have a nice hook for it in the Authoring MFE, useContentTaxonomyTagsData(). As long as you make the request in parallel with the "get block metadata" request, it's really not any less efficient. In fact, it's now considered best practice to make several small requests like that at the same time rather than one "big" request, because the "big" request often computes data that isn't needed - like tags_count in this place isn't needed in many places.

Edit: in fact, the tags widget is probably going to be calling that same API anyways, so it's actually more efficient to re-use the same useContentTaxonomyTagsData hook (react-query will de-duplicate the request) rather than adding an additional query to the metadata API.

@bradenmacdonald Thanks! It's true! I updated the MFE PR with your suggestion: openedx/frontend-app-authoring@0ec25b4

But before these changes, tags_count was not used, I was wondering if we should remove it?

@bradenmacdonald
Copy link
Contributor

But before these changes, tags_count was not used, I was wondering if we should remove it?

Good point. We should remove it. It's confusing to have there if it's not used.

@ChrisChV ChrisChV force-pushed the chris/FAL-3847-add-tags-count-library-block-metadata branch from 7dc6100 to 50c7886 Compare September 27, 2024 00:08
@ChrisChV ChrisChV force-pushed the chris/FAL-3847-add-tags-count-library-block-metadata branch from 50c7886 to d89329c Compare September 27, 2024 00:10
@ChrisChV ChrisChV changed the title fix: Add tags count to library block metadata [FC-0062] fix: Delete tags_count from LibraryXBlockMetadata [FC-0062] Sep 27, 2024
@ChrisChV
Copy link
Contributor Author

@rpenido @bradenmacdonald I updated this PR to delete tags_count, it's ready for review

Copy link
Contributor

@bradenmacdonald bradenmacdonald left a comment

Choose a reason for hiding this comment

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

👍

  • I tested this
  • I read through the code
  • I checked for accessibility issues
  • Includes documentation

@bradenmacdonald bradenmacdonald merged commit de7fa09 into openedx:master Sep 27, 2024
49 checks passed
@bradenmacdonald bradenmacdonald deleted the chris/FAL-3847-add-tags-count-library-block-metadata branch September 27, 2024 17:10
@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX staging environment in preparation for a release to production.

@edx-pipeline-bot
Copy link
Contributor

2U Release Notice: This PR has been deployed to the edX production environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

5 participants