PERF: improve category moderators query (PR #12538)

In the about page, we list a certain number of category moderators.

This rewrites the SQL query used to retrieve the most recent category moderators in order to perform better with a large number of users/categories/category moderators.

It also sort the categories using their position rather than their id.

TIL: you can ORDER BY inside an ARRAY_AGG in postgres TIL: you can slice ARRAYS in postgres


@ZogStriP This ship has sailed (ha, a timely reference! :stuck_out_tongue:) but this code-golf suggestion fits in with the all TILs in the PR description :wink:

    moderators = User.where(id:
1 Like

Nice I didn’t know that one :ok_hand:

1 Like