Closed lczm closed 1 year ago
Hi! The reason for using orderByRaw
instead of orderBy
is to take advantage of sorting by date, without time by typecasting to ::date
. Unless there's another way to sort just the dates with orderBy
that I'm missing (a little unfamiliar with knex & objection, will be happy if there was a way this could work!).
If this was done by using orderBy
, but without typecasting to the date; there will be situations such as:
will sort to
Where it'll put 8am before 7am. Which can be a little unintuitive.
Problem is that auto-filled jios have a start_date of when it is created. This can be solved by reversing the sorting order. There is no need to sort by start_date first, as the primary case for sorting by start_date is to get an ascending order in time for jios.
Describe your changes
Issue ticket number and link
https://github.com/climbjios-sg/climbjios-app/issues/248
Screenshots (if appropriate):
This PR will resort the jios by prioritizing the end dates. This is so that jios with auto-filled dates will not take up all the starting few pages of the feed (as it is previously sorted by start date).
This solution sorts by end_date, specifically using the date, and then by time, to achieve the same outcome in the beginning; to have jios sorted by time. This can be done as jios that have dates filled in, will have the same start & end dates. Solving it this way will also avoid having to over-complicate things by using database migrations.
Checklist before requesting a review