[openstreetmap-website] API: query changesets by ids (#608)

Tom Hughes notifications at github.com
Wed Dec 4 20:26:10 UTC 2013


> @@ -414,6 +415,18 @@ def conditions_closed(changesets, closed)
>    end
>  
>    ##
> +  # query changesets by a list of ids
> +  # (either specified as array or comma-separated string)
> +  def conditions_ids(changesets, ids)
> +    if ids.nil? or ids.empty?
> +      return changesets
> +    else
> +      ids = ids.split(',').collect { |n| n.to_i } if ids.kind_of?(String)
> +      return changesets.where("id IN (?)", ids)

You can just do `:id => ids` here for the condition, and rails will construct an SQL IN for you.

---
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/608/files#r8108844
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20131204/2b597a9c/attachment.html>


More information about the rails-dev mailing list