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

feat: add block_id field to filterable attributes of meilisearch #35493

Merged

Conversation

navinkarkera
Copy link
Contributor

@navinkarkera navinkarkera commented Sep 17, 2024

Adds block_id field to filterable attributes of meilisearch allowing us to fetch a single block/collection from index under a library (context_key).

Supporting information

Testing instructions

Follow instructions in openedx/frontend-app-authoring#1281

Deadline

"None" if there's no rush, or provide a specific date or event (and reason) if there is one.

Other information

Include anything else that will help reviewers and consumers understand the change.

  • Does this change depend on other changes elsewhere?
  • Any special concerns or limitations? For example: deprecations, migrations, security, or accessibility.
  • If your database migration can't be rolled back easily.

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

openedx-webhooks commented Sep 17, 2024

Thanks for the pull request, @navinkarkera!

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.

@@ -1185,6 +1197,8 @@ def update_library_collection_components(
remove=False,
# As an optimization, callers may pass in a pre-fetched ContentLibrary instance
content_library: ContentLibrary | None = None,
# Similarly, users may pass component_keys instead of usage_keys
component_keys: list[str] | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm ok with this change since it saves re-querying data we already have. But I think we shouldn't allow passing in usage_keys if they're providing component_keys instead?

Copy link
Contributor Author

@navinkarkera navinkarkera Sep 19, 2024

Choose a reason for hiding this comment

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

@pomegranited Actually, I need to update the comment. We still need usage_keys as they are used below to trigger CONTENT_OBJECT_ASSOCIATIONS_CHANGED event.

Update: Updated comment

Copy link
Contributor

Choose a reason for hiding this comment

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

Well, we can generate the LibraryUsageLocator keys from component_keys since we have the base library-key, e.g.

usage_key = LibraryUsageLocator(library_key, component.component_type.name, component.local_key)

What do you think? Is it too much to check that either a) component_keys + no usage_keys were passed in or b) the usage_keys provided match the component_keys provided?

Copy link
Contributor

Choose a reason for hiding this comment

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

There should definitely be some sort of validation on the component_keys to make sure they're from the same library.

Personally, I would probably not even have the component_keys parameter for now. It seems a bit like premature optimization, especially when we don't yet have any use of this API to change more than one component at a time (as far as I can see in this PR). But I'm not opposed to leaving it in, as long as there's some more validation.

@navinkarkera navinkarkera force-pushed the navin/add-collections-to-lib-block branch 2 times, most recently from fd379a0 to d911d3c Compare September 19, 2024 14:16
Copy link
Contributor

@pomegranited pomegranited left a comment

Choose a reason for hiding this comment

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

👍 This works perfectly @navinkarkera . I've left an open question about the collection_keys/usage_keys param, but that doesn't have to block merging here.

@@ -1185,6 +1197,8 @@ def update_library_collection_components(
remove=False,
# As an optimization, callers may pass in a pre-fetched ContentLibrary instance
content_library: ContentLibrary | None = None,
# Similarly, users may pass component_keys instead of usage_keys
component_keys: list[str] | None = None,
Copy link
Contributor

Choose a reason for hiding this comment

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

Well, we can generate the LibraryUsageLocator keys from component_keys since we have the base library-key, e.g.

usage_key = LibraryUsageLocator(library_key, component.component_type.name, component.local_key)

What do you think? Is it too much to check that either a) component_keys + no usage_keys were passed in or b) the usage_keys provided match the component_keys provided?

"""
Create a new XBlock in this library of the specified type (e.g. "html").

Optionally associates the newly created xblock with given collection_key.
Copy link
Contributor

@bradenmacdonald bradenmacdonald Sep 20, 2024

Choose a reason for hiding this comment

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

Q: Is it important to assign a collection and create a block in a single API call, as opposed to two API calls? We don't have an API to set any other things during creation, like tags, display name, content, etc. - those are done by follow-up calls. Is there something special about collections?

Copy link
Contributor

Choose a reason for hiding this comment

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

That's a good point -- there's nothing special about collections or how they're indexed that requires doing this in a single step.

We'd still need the filterable fields update, but not the rest of this PR.. @navinkarkera what do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@bradenmacdonald, @pomegranited Yes, that makes sense. I have removed the commit which added collections during creation and updated frontend PR to make an additional api call.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks! I definitely feel better keeping it simple for now.

@navinkarkera navinkarkera force-pushed the navin/add-collections-to-lib-block branch from d911d3c to 610aaf3 Compare September 20, 2024 06:56
@navinkarkera navinkarkera changed the title feat: associate collection on library block creation feat: add block_id field to filterable attributes of meilisearch Sep 20, 2024
@ChrisChV ChrisChV merged commit c71414a into openedx:master Sep 20, 2024
49 checks passed
@ChrisChV ChrisChV deleted the navin/add-collections-to-lib-block branch September 20, 2024 17:12
@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.

6 participants