[openstreetmap/openstreetmap-website] Sort and order notes (#2381)
ENT8R
notifications at github.com
Mon Oct 7 10:55:46 UTC 2019
ENT8R commented on this pull request.
> - @notes = @notes.order("updated_at DESC").limit(result_limit).preload(:comments)
+ @notes = if params[:sort] == "created_at"
+ if params[:order] == "oldest"
+ @notes.order("created_at ASC")
+ else
+ @notes.order("created_at DESC")
+ end
+ else
+ if params[:order] == "oldest"
+ @notes.order("updated_at ASC")
+ else
+ @notes.order("updated_at DESC")
+ end
+ end
+
+ @notes = @notes.distinct.limit(result_limit).preload(:comments)
BTW: I also added `.distinct` which was missing before but might also be useful because returning the same note multiple times is not really helpful...
--
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/2381#pullrequestreview-298046312
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20191007/e3894307/attachment-0001.html>
More information about the rails-dev
mailing list