LemmyNet / lemmy

🐀 A link aggregator and forum for the fediverse
https://join-lemmy.org
GNU Affero General Public License v3.0
13.23k stars 877 forks source link

Add sort order parameter to moderation report endpoints #4581

Open EricBAndrews opened 6 months ago

EricBAndrews commented 6 months ago

Requirements

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.

Additional context

No response

dessalines commented 6 months ago

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.