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: remove unpublished from collections [FC-0062] #252

Conversation

ChrisChV
Copy link
Contributor

@ChrisChV ChrisChV commented Oct 28, 2024

Description

Add remove_unpublished_from_collections in api. Removes all unpublished entities from collections for a given learning package. One use case for this function is when reverting a library to published version. If a collection of a library has unpublished entities and the library is reverted to the published version, the unpublished entities need to be removed to reflect the published state of the library

Support information

Github issue: openedx/modular-learning#234
Internal ticket: FAL-3921
Used on: openedx/edx-platform#35734

Testing instructions

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

openedx-webhooks commented Oct 28, 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 @axim-engineering. 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 October 28, 2024 23:42
@ChrisChV ChrisChV marked this pull request as ready for review October 29, 2024 18:45
@ChrisChV ChrisChV changed the title feat: remove unpublished from collections feat: remove unpublished from collections [FC-0062] Oct 30, 2024
def remove_unpublished_from_collections(learning_package_id: int) -> None:
"""
Removes all unpublished entities from collections for a
given learning package.
Copy link
Contributor

Choose a reason for hiding this comment

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

@ChrisChV Can you please add an explanation/example of why we need this API, and what it's used for?

Copy link
Contributor

Choose a reason for hiding this comment

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

Also as part of the PR and commit message please :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

One use case for this function is when reverting to published.
If a collection has unpublished entities and the learning package is reverted
to the published version, the unpublished entities need to be removed.
@ChrisChV ChrisChV force-pushed the chris/FAL-3873-remove-unpublished-from-collections branch from 72f9463 to 3b940ce Compare November 1, 2024 01:02

One use case for this function is when reverting to published.
If a collection has unpublished entities and the learning package is reverted
to the published version, the unpublished entities need to be removed.
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 this API call would have unintended side-effects, since there may be many Collections that have unpublished things in them. Doing a revert shouldn't empty them all out.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Doing a revert shouldn't empty them all out.

I understand that, in the context of libraries, it should be empty if no component is published. When a library is published, all its components, including those belonging to collections, are published. Similarly, when reverting, all components, including those belonging to collections, are discarded.

Since it is in the context of libraries, this function is only called when reverting a library, and has not been added when reverting any learning_package

I updated the comment to specify that the use case is in the context of libraries: e16f6a2

Copy link
Contributor

Choose a reason for hiding this comment

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

If a library has components that were never published, but they've been added to a collection: when you "revert changes" to the library, those components should be essentially deleted. In that case, the deletion should already be propagating to the collection model. If not, that's a bug we need to fix in here - but shouldn't require an explicit API call.

If a library has components that were published then modified and/or added to new collections: when you "revert changes" to the library, the changes to the components should be reset so they match the published version. But, they will still be in any new collections that they've been added to. This is because tags and collections are not part of the draft-publish workflow.

Does that make sense? If so, I don't think we need this proposed API.

Copy link
Contributor

Choose a reason for hiding this comment

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

@bradenmacdonald: I think we worked this out in the issue thread: openedx/modular-learning#234 (comment)

@ChrisChV
Copy link
Contributor Author

ChrisChV commented Nov 7, 2024

Closed, It's no longer used

@ChrisChV ChrisChV closed this Nov 7, 2024
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
Archived in project
Development

Successfully merging this pull request may close these issues.

5 participants