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

ordered_by for external content fetching, not only queryset #4

Open
weber-s opened this issue Jun 23, 2023 · 1 comment
Open

ordered_by for external content fetching, not only queryset #4

weber-s opened this issue Jun 23, 2023 · 1 comment
Labels
enhancement New feature or request
Milestone

Comments

@weber-s
Copy link
Member

weber-s commented Jun 23, 2023

For now, the ordered_by kwarg is use only for objects already fetch

    def get_queryset(self, *args: tuple, **kwargs: dict) -> QuerySet:
        """
        Return the queryset filtered by app + contentype and optionaly channel and channel object
        if it's given
        """
        qs = super().get_queryset(*args, **kwargs)
        [...]

        if self.ordered_by:
            order = ""
            if self.ordered_by.startswith("-"):
                order = "-"
                ordered_by = self.ordered_by[1:]
            else:
                ordered_by = self.ordered_by
            qs = qs.order_by(f"{order}content_data__{ordered_by}")
        return qs

however many API endpoint support sorting as well (e.g gitlab milestone) but have default ordering. So retrieving default "10 milestone" would be the "10 first created" using default gitlab milestone API endpoint. But let's say we want the "10 last updated" or "10 last created" (i.e. most recent ones)? It would be super useful to allow sorting at the proxy level.

@weber-s weber-s added the enhancement New feature or request label Jun 23, 2023
@DylannCordel DylannCordel added this to the 0.3.0 milestone Feb 21, 2024
@DylannCordel
Copy link
Member

LGFM if someone want to code it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants