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

Add tags/roles and tags/collections endpoints #1931

Conversation

jerabekjiri
Copy link
Contributor

@jerabekjiri jerabekjiri commented Oct 11, 2023

Issue: AAH-2761

  • add sorting by name and count for both endpoints
  • filter by name, name__icontains, name__contains, name__startswith for both endpoints

_ui/v1/tags/collections:

_ui/v1/tags/roles:

  • To populate tags endpoint: django-admin populate-role-tags
GET /api/_ui/v1/tags/roles/
{
    "meta": {
        "count": 10
    },
    "links": {
        "first": "/api/_ui/v1/tags/roles/?limit=10&offset=0",
        "previous": null,
        "next": null,
        "last": "/api/_ui/v1/tags/roles/?limit=10&offset=0"
    },
    "data": [
        {
            "name": "firefox",
            "count": 5
        },
        {
            "name": "development",
            "count": 3
        },
        {
            "name": "workstation",
            "count": 1
        },
        {
            "name": "bfg",
            "count": 1
        }
    ]
}

@github-actions github-actions bot added backport-4.2 This PR should be backported to stable-4.2 (1.2) backport-4.4 This PR should be backported to stable-4.4 (2.1) backport-4.5 This PR should be backported to stable-4.5 (2.2) backport-4.6 This PR should be backported to stable-4.6 (2.3) backport-4.7 This PR should be backported to stable-4.7 (2.4) backport-4.8 This PR should be backported to stable-4.8 (2.4) labels Oct 11, 2023
@jerabekjiri jerabekjiri removed backport-4.2 This PR should be backported to stable-4.2 (1.2) backport-4.4 This PR should be backported to stable-4.4 (2.1) backport-4.5 This PR should be backported to stable-4.5 (2.2) backport-4.6 This PR should be backported to stable-4.6 (2.3) backport-4.7 This PR should be backported to stable-4.7 (2.4) backport-4.8 This PR should be backported to stable-4.8 (2.4) labels Oct 11, 2023
@jerabekjiri jerabekjiri force-pushed the feature/roles-and-collections-tags-endpoint branch from 878da66 to db2075f Compare October 16, 2023 14:23
order = "-" if "-count" in value else ""

return qs.filter(
ansible_collectionversion__ansible_crossrepositorycollectionversionindex__is_highest=True # noqa: E501
Copy link
Member

Choose a reason for hiding this comment

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

does it really need to use the crossrepo index? for community we have only one repo and it would be faster to just take the is_highest from the single repo.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's true, but then this wouldn't work for PAH and CRC

@jerabekjiri jerabekjiri force-pushed the feature/roles-and-collections-tags-endpoint branch from db2075f to 750d2c7 Compare October 26, 2023 10:39
@jerabekjiri
Copy link
Contributor Author

/retest

Copy link
Collaborator

@jctanner jctanner left a comment

Choose a reason for hiding this comment

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

Let's try it out and see how it goes.


class Migration(migrations.Migration):
dependencies = [
("galaxy", "0041_alter_containerregistryremote_remote_ptr"),
Copy link
Collaborator

Choose a reason for hiding this comment

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

0042_namespace_created_namespace_updated ?

(there's a new migration if you rebase .. and this bit seems to produce an infinite loop when starting)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch 👍, rebased.

@himdel
Copy link
Collaborator

himdel commented Nov 1, 2023

The collections endpoint seems to work, but the items are missing count.
The roles endpoint returns 0 items even after I imported some roles with tags.

Do I need to trigger some manage command to regenerate, have a flag enabled, or something?

Issue: AAH-2761
Issue: AAH-2761
Issue: AAH-2761
Issue: AAH-2761
Issue: AAH-2761
Issue: AAH-2761
Issue: AAH-2761
@jerabekjiri
Copy link
Contributor Author

@himdel

The collections endpoint seems to work, but the items are missing count.

count will be included in next pulp_ansible release pulp/pulp_ansible#1612

The roles endpoint returns 0 items even after I imported some roles with tags.

Do I need to trigger some manage command to regenerate, have a flag enabled, or something?

Good point, I forgot to mention that you need to run django-admin populate-role-tags to populate tags. Sorry about that

@jerabekjiri jerabekjiri force-pushed the feature/roles-and-collections-tags-endpoint branch from 750d2c7 to 7e7f008 Compare November 1, 2023 11:35
Copy link
Collaborator

@himdel himdel left a comment

Choose a reason for hiding this comment

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

Thanks! :) Works for me, I can see role tag counts now 👍

@jerabekjiri jerabekjiri merged commit 5a6a780 into ansible:master Nov 1, 2023
20 of 21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants