edx-platform icon indicating copy to clipboard operation
edx-platform copied to clipboard

Store content object collections in search index [FC-0062]

Open pomegranited opened this issue 1 year ago • 1 comments

Description

This PR ensures that when a content object is added/removed from a Collection, its search index document is updated to reflect this change. The collection.key values for each collection are stored in a new collections list.

To support this, we added a new event called CONTENT_OBJECT_ASSOCIATIONS_CHANGED, and trigger it when an object's collections change. This event is also now triggered when an object's tags change. The previous CONTENT_OBJECT_TAGS_CHANGED event is still emitted for tag changes, but is now deprecated.

Useful information to include:

  • Which edX user roles will this change impact? Course Authors who have enabled Content Libraries V2.

Supporting information

Related Tickets:

  • https://github.com/openedx/modular-learning/issues/230
  • Private-ref: FAL-3787

Depends on / blocked by:

  • https://github.com/openedx/edx-platform/pull/35321 -- see https://github.com/open-craft/edx-platform/pull/680 for code review.

Testing instructions

  • Setup tutor with this PR and https://github.com/open-craft/tutor-contrib-meilisearch plugin, plus ensure you are running with the latest versions of openedx-learning + openedx-events.
  • Run migrations: tutor dev run cms python manage.py migrate
  • In the content-authoring MFE, create a library, e.g. lib:SampleTaxonomyOrg1:AL1
  • Add some blocks to the library, and note their block keys. Hint: you can retrieve the block keys using the REST API, e.g. http://studio.local.edly.io:8001/api/libraries/v2/lib:SampleTaxonomyOrg1:AL1/blocks/
  • Run tutor dev run cms ./manage.py cms reindex_studio --experimental to add the new collections field.
  • Run below snippet to add some collections -- reindexing should happen automatically.
# tutor dev run cms python manage.py cms shell
from opaque_keys.edx.keys import UsageKey
from opaque_keys.edx.locator import LibraryLocatorV2
from openedx.core.djangoapps.content_libraries import api                                                                                                
lib_key_str = "lib:<your lib key>"
block_key_strs = [
    "lb:<your block key",
    "lb:<your block key",
    # ....
]

library_key = LibraryLocatorV2.from_string(lib_key_str)
block_keys = [
    UsageKey.from_string(key_str) for key_str in block_key_strs
]

api.create_library_collection(library_key, "FAL-3787", title="Collection FAL-3787")
api.update_library_collection_components(library_key, "FAL-3787", usage_keys=block_keys)
# <Collection> (lp:1 FAL-3787:Collection FAL-3787) 
  • Open http://meilisearch.local.edly.io:7700/ Your api key can be found with tutor config printvalue MEILISEARCH_API_KEY
  • Search for FAL-3787 and verify that each of your blocks has FAL-3787 showing in its collections list.

Deadline

Before Sumac gets cut in October.

pomegranited avatar Sep 11 '24 02:09 pomegranited

Thanks for the pull request, @pomegranited!

What's next?

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

:radio_button: 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.

:radio_button: 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

:radio_button: 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.

:radio_button: 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

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

openedx-webhooks avatar Sep 11 '24 02:09 openedx-webhooks

@ChrisChV I think it's worth merging https://github.com/open-craft/edx-platform/pull/684 into here first before we merge this change -- it contains a number of necessary fixes and additions.

pomegranited avatar Sep 12 '24 06:09 pomegranited

@pomegranited I will merge this tomorrow morning

ChrisChV avatar Sep 13 '24 00:09 ChrisChV

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

edx-pipeline-bot avatar Sep 13 '24 14:09 edx-pipeline-bot

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

edx-pipeline-bot avatar Sep 13 '24 17:09 edx-pipeline-bot

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

edx-pipeline-bot avatar Sep 13 '24 17:09 edx-pipeline-bot