Default sort order for posts needs to consider status 'scheduled'
See original GitHub issueThe orderDefaultOptions() for posts model return a sort order which needs to be updated in regards of the new scheduling feature (#6861). Status quo the order is
- status: ‘ASC’,
- published_at: ‘DESC’,
- updated_at: ‘DESC’,
- id: ‘DESC’.
This worked out well so far, because we want to have posts with status ‘draft’ before posts with status ‘published’ and the usual alphabetical, ascending order (d before p) works fine.
Now, as we expanded the posts to also have a status ‘scheduled’, these posts would always be last in order, if we’d remain the regular order.
For usability reasons, ‘scheduled’ posts should be listed first. Then ‘draft’ and finally ‘published’.
I suggest to return a custom sorting function (if needed), which returns the order like this:
1. status: 1. scheduled, 2. draft, 3. published 2. published_at: ‘DESC’, 3. updated_at: ‘DESC’, 4. id: ‘DESC’
The comparison between a ‘draft’ and ‘published’ can stay the same, as the alphabetical order is valid here. Anytime a ‘scheduled’ post is compared with a different status, it should get the higher priority in the order. published_at
, updated_at
and id
will remain unaffected.
Reason, why we have to do this:
The API endpoint is paginated so we need the server to return the posts in the right order by default or have some way to instruct the server to return posts in the order that we want.
^ thanks @kevinansfield
Issue Analytics
- State:
- Created 7 years ago
- Comments:13 (12 by maintainers)
Top GitHub Comments
I will care about the ordering on the server side asap.
My 2 cents about the description:
I don’t think this is good from a usability perspective: I’d rather see posts move down in a list from “draft” (top) to “scheduled” to “published” (bottom).
Think about it: If the UI showed scheduled first, the post starts in the middle of the list (assuming other posts are already scheduled), then moves up to scheduled, then all the way down to scheduled based on time.
I imagine this to be very confusing to users.