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

Improve the "get object tags" API [FC-0036] #111

Merged

Conversation

bradenmacdonald
Copy link
Contributor

@bradenmacdonald bradenmacdonald commented Oct 31, 2023

openedx/modular-learning#133

This PR updates the "get object tags" API so that it returns the results grouped by taxonomy, and sorted into "tree order" (just like the "get tags" API does).

I've also added a new API that can retrieve the # of tags applied to each unit for every unit on the course, in a single database query.

TODO

Before merging, check how this integrates into edx-platform.

Follow up

I could do a separate PR to allow including "available but unused" taxonomies in the result - those which don't yet have any tags applied to the object, but which the user could use to add additional tags. The permissions of that are somewhat complicated though so it's best as its own PR. Or perhaps it's fine to make the frontend construct this just by querying the list of available taxonomies directly, and appending them to its own list.

Private ref: FAL-3547

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

openedx-webhooks commented Oct 31, 2023

Thanks for the pull request, @bradenmacdonald! Please note that it may take us up to several weeks or months to complete a review and merge your PR.

Feel free to add as much of the following information to the ticket as you can:

  • supporting documentation
  • Open edX discussion forum threads
  • timeline information ("this must be merged by XX date", and why that is)
  • partner information ("this is a course on edx.org")
  • any other information that can help Product understand the context for the PR

All technical communication about the code itself will be done via the GitHub pull request interface. As a reminder, our process documentation is here.

Please let us know once your PR is ready for our review and all tests are green.

}
],
},
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@yusuf-musleh If I make the "get object tags" API return data like this, it should make the unit tags overlay much simpler, right?

            assert response.data == {
                "problem15": {
                    "taxonomies": [
                        {
                            "name": "Life on Earth",
                            "taxonomy_id": 1,
                            "editable": True,
                            "tags": [
                                {
                                    "name": "Life on Earth",
                                    "value": "Mammalia",
                                    "lineage": ["Eukaryota", "Animalia", "Chordata", "Mammalia"],
                                },
                                {
                                    "name": "Life on Earth",
                                    "value": "Fungi",
                                    "lineage": ["Eukaryota", "Fungi"],
                                },
                            ]
                        },
                        {
                            "name": "user AUthors",
                            "taxonomy_id": 3,
                            "editable": False,
                            "tags": [
                                {
                                    "name": "User Authors",
                                    "value": "test_user_1",
                                    "lineage": ["test_user_1"],
                                },
                            ],
                        }
                    ],
                },
            }

Copy link
Contributor

Choose a reason for hiding this comment

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

@bradenmacdonald Absolutely! This would make things much simpler. In the currently implementation there's a bunch of stitching stuff together, having this would reduce the API calls needed, especially if the taxonomies returned included taxonomies that are "available" and not only limited to ones that have their tags applied to the object (unit).

@bradenmacdonald bradenmacdonald force-pushed the braden/object-tags-multi-retrieve branch 3 times, most recently from ec17ef3 to a7d00e0 Compare November 1, 2023 21:11
@bradenmacdonald bradenmacdonald force-pushed the braden/object-tags-multi-retrieve branch 2 times, most recently from 1f5a4e5 to 58afaff Compare November 1, 2023 21:42
@bradenmacdonald bradenmacdonald changed the title Retrieve tags for multiple objects at once [FC-0036] [WIP] Improve the "get object tags" API [FC-0036] [WIP] Nov 1, 2023
@bradenmacdonald bradenmacdonald force-pushed the braden/object-tags-multi-retrieve branch from 58afaff to 0fb7eb9 Compare November 1, 2023 21:45
@bradenmacdonald bradenmacdonald force-pushed the braden/object-tags-multi-retrieve branch from 0fb7eb9 to 2858e1b Compare November 1, 2023 21:48
@bradenmacdonald bradenmacdonald added the FC Relates to an Axim Funded Contribution project label Nov 1, 2023
@bradenmacdonald bradenmacdonald changed the title Improve the "get object tags" API [FC-0036] [WIP] Improve the "get object tags" API [FC-0036] Nov 1, 2023
@bradenmacdonald
Copy link
Contributor Author

@pomegranited I think this is ready for review, though I may need to make some changes once I try to integrate it into edx-platform. Haven't done that side of it yet.

Copy link
Contributor

@pomegranited pomegranited left a comment

Choose a reason for hiding this comment

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

Couple of nits, but this looks and works great @bradenmacdonald ! 👍

  • I tested this using the Django runserver
  • I read through the code
  • I checked for accessibility issues N/A
  • Includes documentation
  • Commit structure follows OEP-0051

tests/openedx_tagging/core/tagging/test_views.py Outdated Show resolved Hide resolved
tests/openedx_tagging/core/tagging/test_views.py Outdated Show resolved Hide resolved
@bradenmacdonald bradenmacdonald merged commit a248f35 into openedx:main Nov 2, 2023
7 checks passed
@openedx-webhooks
Copy link

@bradenmacdonald 🎉 Your pull request was merged! Please take a moment to answer a two question survey so we can improve your experience in the future.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
FC Relates to an Axim Funded Contribution project 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.

4 participants