X-Git-Url: https://git.openstreetmap.org./rails.git/blobdiff_plain/def60c193514a0d5067d5c0b007421e1a472b73b..98d49ed14497e3af8367d8f42af9d9b760dcaba7:/app/models/relation.rb diff --git a/app/models/relation.rb b/app/models/relation.rb index bdba25f8f..c8516b58a 100644 --- a/app/models/relation.rb +++ b/app/models/relation.rb @@ -105,6 +105,36 @@ class Relation < ActiveRecord::Base return el1 end + def self.find_for_nodes(ids, options = {}) + if ids.empty? + return [] + else + self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'node' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do + return self.find(:all, options) + end + end + end + + def self.find_for_ways(ids, options = {}) + if ids.empty? + return [] + else + self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'way' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do + return self.find(:all, options) + end + end + end + + def self.find_for_relations(ids, options = {}) + if ids.empty? + return [] + else + self.with_scope(:find => { :joins => "INNER JOIN current_relation_members ON current_relation_members.id = current_relations.id", :conditions => "current_relation_members.member_type = 'relation' AND current_relation_members.member_id IN (#{ids.join(',')})" }) do + return self.find(:all, options) + end + end + end + # FIXME is this really needed? def members unless @members @@ -234,4 +264,8 @@ class Relation < ActiveRecord::Base return false end + # Temporary method to match interface to nodes + def tags_as_hash + return self.tags + end end