Delete tag updates meilisearch#571
Conversation
|
Thanks for the pull request, @mgwozdz-unicon! This repository is currently maintained by Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review. 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo 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:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. DetailsWhere 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:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
0901700 to
2018c05
Compare
| if isinstance(origin, Tag): | ||
| return origin.pk == instance.pk | ||
|
|
||
| if not isinstance(origin, QuerySet) or origin.model is not Tag: |
There was a problem hiding this comment.
Is this a runtime error, i.e. should we be raising a TypeError here?
There was a problem hiding this comment.
I don't think so. I think we want this to just be a no-op so that an unexpected type doesn't result in aborting or rolling back the delete operation. Let me know if you disagree.
There was a problem hiding this comment.
If there is no known reason to have gotten into this state, please raise a TypeError here. As far as I can see, this is only being invoked from a place where you're specifically listening to Tag as the sender, so if it's anything other than these two, something is really broken, and it's better to break loudly so that the issue can be found more quickly.
ormsbee
left a comment
There was a problem hiding this comment.
Handful of questions/requests. Thank you.
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
| ) | ||
| ObjectTag.objects.create( | ||
| object_id=delta_object_id, | ||
| taxonomy=self.delta.taxonomy, |
There was a problem hiding this comment.
It is confusing when reading this test in isolation, because the tags self.alice and self.delta appear to be coming from two difference taxonomies (self.alice.taxonomy vs. self.delta.taxonomy). I don't think this test belongs in TestTagLineage at all. The 4 or 5 tests related to event emitting should be in a separate test_events.py module.
I won't block the PR on this but I'd strongly prefer to see it at least flagged as a TODO if not moved before merge.
| Descendants deleted via CASCADE are skipped here because the explicit root | ||
| tag's handler emits updates for the whole subtree. |
There was a problem hiding this comment.
Just curious, is there any reason this approach (using _is_explicit_tag_delete, manually emitting events for the descendants, and then suppressing events for the CASCADE) is preferable to just listening for each individual Tag deletion and emitting an event for each one, including the CASCADE deletes (but never manually emitting events for the descendants)?
The latter seems like it would have much simpler code since you wouldn't need this _is_explicit_tag_delete logic. But perhaps it's not as performant?
There was a problem hiding this comment.
It's to prevent duplicate events per object so that it emits one event per object regardless of how many tags in the subtree are applied to it. This does improve performance with N cascade deletes --> N tasks --> N sets of DB queries in the simple approach, versus 1 task with 1 query in the current approach. For large taxonomies this could be significant.
There was a problem hiding this comment.
That makes sense, and would be worth mentioning in the code.
Even with that optimization, the number of events emitted could be huge, but since they're in a celery task it should be OK.
I'm dismissing my review so it doesn't block the merge if Braden gives his approval. I may not be back until much later this evening.
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Description
This PR in conjunction with the openedx-platform PR (openedx/openedx-platform#38477) is the backend component for openedx/modular-learning#260. This PR ensures that when a tag and its descendants are deleted that CONTENT_OBJECT_ASSOCIATIONS_CHANGED events take place for each associated object with no duplicates. The openedx-platform PR ensures that once those events happen, the entire search document is replaced for the relevant content.
Goal:
When a Course Author deletes a tag that is associated to Library content, they should be able to return to the Library page and not see those tags in the tag search filter.
Supporting information
Github Issue: openedx/modular-learning#260
Testing instructions
Note: This cannot be tested without the code from the following PRs in place:
Deadline
This is for our Verawood code cut stretch goal.
Other information
While this code requires other PRs in place to be able to test, I believe it can be safely merged without them.