Conversation
…ement counting logic with unit tests
|
Thanks for the pull request, @tbain! 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. |
jesperhodge
left a comment
There was a problem hiding this comment.
There seem to be changes missing. For example, src/taxonomy/data/api.ts.
Could you
- review this PR and make sure that all necessary changes are in this branch? Compare to the open Unicon PR.
- review discussions in the Unicon PR and either resolve them or copy them here to be addressed here.
- fix any pipeline errors
?
|
Since we're no longer using recursive SQL for this, is it possible to update the PR description for accuracy? |
|
…bain/253_add_tags_count_rebased # Conflicts: # src/openedx_tagging/models/base.py # tests/openedx_tagging/test_api.py
There was a problem hiding this comment.
Pull request overview
Adds rolled-up, de-duplicated tag usage counts (including ancestor rollups) to the tag listing query so the Taxonomies UI can display accurate “Usage Count” values per tag.
Changes:
- Replaced the prior per-tag direct usage counting subquery with a dynamic, depth-aware subquery that rolls counts up to ancestors with per-object de-duplication.
- Updated existing API/model tests to reflect rolled-up counts and added a broader set of usage-count test cases.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 9 comments.
| File | Description |
|---|---|
src/openedx_tagging/models/base.py |
Centralizes and updates include_counts behavior by annotating tag querysets with rolled-up, de-duplicated usage_count via a subquery. |
tests/openedx_tagging/test_models.py |
Updates expected usage counts and adds multiple new test scenarios validating ancestor rollup and sibling de-duplication. |
tests/openedx_tagging/test_api.py |
Updates autocomplete/search test expectations to reflect rolled-up usage counts returned by the API when include_counts=True. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
Feel free to ping me for review here once the AC are clarified and the comments from Copilot etc are addressed. |
@bradenmacdonald I think this is ready for re-review, I resolved all the Copilot issues and added the improvement you suggested for finding the depth via a query rather than depending on the constant |
…t & filter query to current taxonomy
|
When I test this using |
| """ | ||
| Test that the usage count is correct and parent counts are included based on | ||
| child tags being added to an object. However, we de-duplicate and only count | ||
| 1 parent tag towards a course even if 2 children are applied to that course |
There was a problem hiding this comment.
| 1 parent tag towards a course even if 2 children are applied to that course | |
| 1 parent tag towards each object even if 2 children are applied to that object | |
| (to reflect that the UI for that object would show 1 implicit parent tag and 2 | |
| explicit child tags). |
This description (and the test name) makes it sound like we are aware of the context of objects within courses, but we are not. There is no logic related to "courses" specifically in the query.
Object 1, Course A: grandchild tag
Object 2, Course A: grandchild tag
Object 3, Course B: grandchild tag
Overall usage count for the common parent of "grandchild tag" should be "3", because these are all distinct objects and it doesn't matter that two of them are in the same course.
| " Animalia (used: 4, children: 7 + 1)", | ||
| " Arthropoda (used: 1, children: 0)", | ||
| " Chordata (used: 0, children: 1)", | ||
| " Chordata (used: 0, children: 1)", # <<< Chordata has a matching child but we only support searching |
There was a problem hiding this comment.
What does this comment mean? Was it added accidentally during a merge/rebase?
|
I'm not opposed to this PR as is, but a 10x slowdown isn't great, and I suspect it may be worse if there are more ObjectTags in use (I don't have that many in my test environment). In order to improve performance, I have two suggestions:
Thoughts? |
Description
This implements openedx/modular-learning#253 , the task to add tag usage counts to the tags table under the taxonomies table. The frontend piece is where the results of this aggregation work is displayed is part of a separate pr to openedx/frontend-app-authoring. This change adds a subquery annotation onto the django query for retrieving tags. The original implementation of the counts for tags only counted raw usage of each tag, rather than aggregate sum of any tag and child tag usage with sibling de-duplication for the same usage (e.g. when two sibling nodes are used against the same course, module, etc. we still only need to count that as '1' for any parent/grandparent nodes) as specified in the AC for the issue above, so it was replaced with this more complicated sub-query that sums across tag usage based on various courses, sections, modules, and libraries that might use a tag.
Supporting information
Github issue with AC: openedx/modular-learning#253
Testing instructions
Refer to the AC in the Github Issue. Steps to verify this is implemented and working via UX (Note, depends on the frontend part of this ticket):
Other information
Include anything else that will help reviewers and consumers understand the change.