lemmy icon indicating copy to clipboard operation
lemmy copied to clipboard

Add sort order parameter to moderation report endpoints

Open EricBAndrews opened this issue 1 year ago • 1 comments

Requirements

  • [X] Is this a feature request? For questions or discussions use https://lemmy.ml/c/lemmy_support
  • [X] Did you check to see if this issue already exists?
  • [X] Is this only a feature request? Do not put multiple feature requests in one issue.
  • [X] Is this a backend issue? Use the lemmy-ui repo for UI / frontend issues.
  • [X] Do you agree to follow the rules in our Code of Conduct?

Is your proposal related to a problem?

Currently, post reports, comment reports, and registration applications sort by publication date in descending order by default and in ascending order when unresolved_only is true, while private message reports are always returned in descending order by publication date of the message itself. This renders it impossible to display a sorted feed of all unresolved reports.

Describe the solution you'd like.

I propose adding an ascending/descending sort_order parameter to the API endpoint that, if present, overrides the default sorting behavior with the specified ordering.

Describe alternatives you've considered.

  • Sort client-side: possible for the first page, but sorting issues emerge on later pages. Re-sorting every page fetch is infeasible as new items will be inserted at the top of the feed, out of the user's sight.
  • Fetch all (or a large number of) items and filter client-side: slow and bad API citizenship

Additional context

No response

EricBAndrews avatar Apr 02 '24 01:04 EricBAndrews

while private message reports are always returned in descending order by publication date of the message itself.

That seems to be the main bug here. The sorting logic in the code is:

If viewing all reports, order by newest, but if viewing unresolved only, show the oldest first (FIFO)

I don't know if we'd want to complicate that logic by moving it client side. Probably best to not have a sort parameter, and let the back end apply the above rule.

Combining these types and properly sorting them is limited by #2444 . Because rn they could have wildly different time ranges.

dessalines avatar Apr 02 '24 14:04 dessalines