-
Notifications
You must be signed in to change notification settings - Fork 18
Reduce the number of queries used in tagging API [FC-00036] #157
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
Changes from all commits
163ee41
6464f53
ad7838e
e36e074
5f308ee
77f8282
dc86603
29e644e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| """ | ||
| Open edX Learning ("Learning Core"). | ||
| """ | ||
| __version__ = "0.6.1" | ||
| __version__ = "0.6.2" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -100,6 +100,13 @@ def to_representation(self, instance): | |
| return super().to_representation(instance) | ||
|
|
||
| def get_tags_count(self, instance): | ||
| """ | ||
| Return the "tags_count" annotation if present. | ||
|
|
||
| Or just count the taxonomy's tags. | ||
| """ | ||
| if hasattr(instance, 'tags_count'): | ||
| return instance.tags_count | ||
|
Comment on lines
+108
to
+109
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Did this help reduce the query count? The reason I ask is because on the commit that this was added in, the query counts in the tests did not change, so I was just wondering what effect this may have had.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The query counts dropped here when this branch was used: openedx/openedx-platform@016f2a5 |
||
| return instance.tag_set.count() | ||
|
|
||
| def get_can_tag_object(self, instance) -> bool | None: | ||
|
|
||
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.
Note: I used code from this blog to make this change. That blog post also copies the caches for one-to-many fields that were cached using
select_related, but since Taxonomy doesn't have any one-to-many fields, I omitted that part.