The Project list on the dashboard seems to be sorted after the paging is done. This results in having projects recently updated on page 2 while they should be on top of page 1.
Designs
Child items
...
Show closed items
Linked items
0
Link issues together to show that they're related or that one is blocking others.
Learn more.
defprojects_with_eventsprojects.order("(SELECT max(events.created_at) FROM events WHERE events.project_id = projects.id) DESC")end
JOINs are big evil for big tables like "events", better way is using subqueries.
I've just removed "events" table from inclusion and use tricky ORDER BY with subquery.
If it need, events are included later automatically with couple of simple subqueries for each project in list on dashboard like this:
My solution also fixes bug with Postgresql and Arel - for projects.includes(:events).order("events.created_at DESC") and next @projects.page(params[:page]).per(30) Postgresql-builded query for finding project ids looks like:
DISTINCT statement in Postgresql cannot be used without fields in ORDER BY statement (Postgresql ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list)
So, DISTINCT condition for this query applies to pair ("projects".id, events.created_at) and it is completely wrong with LIMIT statement. See my result example:
Project ids are duplicated and worse - some projects with old activity (more than 30 events ago) simply cut off from result and lose in projects list on dashboard.
P.S. subquery in ORDER BY statement works fine in sqlite3 and mysql as well.
By Administrator on 2012-11-16T16:45:44 (imported from GitLab)
Kewl!.. Thanks!
Can you make pull request with your fix on this issue? It's easy to do: just make a fork, then make branch and then make pull request.
Thanks again!
By Administrator on 2012-11-17T12:27:21 (imported from GitLab)