-
Notifications
You must be signed in to change notification settings - Fork 7
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
[FC-0040] feat: update search index when object tags change #647
Conversation
89d451c
to
b2dc9a4
Compare
0d444e4
to
21b8139
Compare
upsert_xblock_index_doc.delay( | ||
content_object_tags.object_id, | ||
recursive=False, | ||
update_metadata=True, | ||
update_tags=True, | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I needed to set update_metadata=True
here, because without it, it was creating new documents when tags are updated, rather than updating the existing one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the new documents' issue is unrelated to this parameter.
We changed the way the ID hash was generated upstream, so the first time you tag an object (after the update), a new document is generated. Could you check if this was the case?
If so, using update_metadata=False
should work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, adding Tags to a LibraryComponent if passing here (and falling).
A suggestion is to refactor and create a new update function for tagging only that can handle both types of blocks calling searchable_doc_for_library_block
or searchable_doc_for_course_block
(and eliminate the update_metadata
and update_tags
parameters from the task). But it's up to you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you check if this was the case?
If so, using update_metadata=False should work.
Yes -- that seemed to fix it and using update_metadata=False
now works! I updated it.
I also added handling tagging for library blocks, I just opted for checking the type of the object_id for the content object and choosing the correct method based on that.
@@ -162,7 +162,7 @@ def _tags_for_content_object(object_id: UsageKey | LearningContextKey) -> dict: | |||
# tags for each component separately. | |||
all_tags = tagging_api.get_object_tags(object_id).all() | |||
if not all_tags: | |||
return {} | |||
return {Fields.tags: {}} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was needed to clear out tags in the index when unselecting all tags for the block, it would remain the last value otherwise because the Fields.tags
value would not be included.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Might be worth mentioning that in the code as a comment :)
61d72bb
to
4a85a61
Compare
f1a94f3
to
a2e9d2a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @yusuf-musleh! Good work here!
I left some suggestions and questions in the review.
a2e9d2a
to
4a55c89
Compare
object_id = kwargs.get('object_id') | ||
CONTENT_OBJECT_TAGS_CHANGED.send_event( | ||
time=now(), | ||
content_object=ContentObjectData(object_id=object_id) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also I wonder, what's an object_id
? What does it look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The object_id
is the id of the course or library block as a string that is being tagged. For example:
block-v1:SampleTaxonomyOrg2+STC1+2023_1+type@vertical+block@f8de78f0897049ce997777a3a31b6ea0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we add that explanation to the event data docstring? Here that would address all my comments. Thank you!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure thing! Updated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left a few comments regarding openedx/openedx-events#327. Also, is this PR going to be open against upstream?
8f39fc6
to
cdde7d7
Compare
Thanks @rpenido and @mariajgrimaldi for your reviews! I've addressed your comments.
Yes, this PR should be opened against upstream master once the base of this PR gets merged. |
b7aef89
to
45b6bf9
Compare
…stones-16b82db feat: Upgrade Python dependency edx-milestones
fix: SSO self-serve tool invalid entityId parsing Commit generated by workflow `openedx/edx-platform/.github/workflows/upgrade-one-python-dependency.yml@refs/heads/master`
…thon_3.11 Make Tests Python 3.11 Compatible
…dx-enterprise-68b3753 feat: Upgrade Python dependency edx-enterprise
…lash feat!: Remove the django-splash app.
feat: re-expose deprecated fragments as passthrough Commit generated by workflow `openedx/edx-platform/.github/workflows/upgrade-one-python-dependency.yml@refs/heads/master` Co-authored-by: connorhaugh <[email protected]> Co-authored-by: connorhaugh <[email protected]>
Update to a Python 3.11 compatible version Commit generated by workflow `openedx/edx-platform/.github/workflows/upgrade-one-python-dependency.yml@refs/heads/master`
Update to a Python 3.11 compatible version Commit generated by workflow `openedx/edx-platform/.github/workflows/upgrade-one-python-dependency.yml@refs/heads/master`
@yusuf-musleh I found a small but significant bug, so I pushed a fix to your PR. And (unrelated) there are some conflicts now. Could you please rebase or merge master into this, then ping me to merge it? |
@@ -116,11 +129,19 @@ def test_reindex_meilisearch_disabled(self, mock_meilisearch): | |||
@override_settings(MEILISEARCH_ENABLED=True) | |||
def test_reindex_meilisearch(self, mock_meilisearch): | |||
|
|||
# Add tags field to doc, since reindex calls with `include_tags=True` internally |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This docstring is out of date - we don't have include_tags=True
anymore
This reverts commit f866545.
…toring-1eb92a3 feat: Upgrade Python dependency edx-proctoring
…-1eb92a3 feat: Upgrade Python dependency edx-rbac
This takes care of updating tags data in search index for both course and library blocks.
b15b9d9
to
32d7d09
Compare
d474406
to
8fc6c45
Compare
@bradenmacdonald Got it, I've addressed your comments, rebased/fixed conflicts and created a new PR off master, thats good to go (openedx#34559). So I'm closing this PR in favor of that one. |
Description
This PR implements updating search index with object tags whenever they change, based on the new
CONTENT_OBJECT_TAGS_CHANGED
event.Supporting Information
CONTENT_OBJECT_TAGS_CHANGED
signal openedx/openedx-events#327Testing Instructions
CONTENT_OBJECT_TAGS_CHANGED
signal openedx/openedx-events#327 and make sure it is accessible from your devstack, and install it locallypip uninstall openedx-events
pip install -e path/to/openedx-events/
meilisearch
setup locally, follow the setup instructions here https://github.com/open-craft/tutor-contrib-meilisearchtutor dev run cms bash
and./manage.py cms reindex_studio
Tags
field in the index document for the block has been updated to reflect that changes you made.Prinvate-ref: FAL-3691