Removed lookup of current element in calls to history

This commit is contained in:
Matt Amos 2012-04-04 19:13:07 +01:00 committed by Tom Hughes
parent c8971a545c
commit 0093db5ffb
4 changed files with 12 additions and 10 deletions

View file

@ -14,9 +14,14 @@ class OldController < ApplicationController
after_filter :compress_output after_filter :compress_output
around_filter :api_call_handle_error, :api_call_timeout around_filter :api_call_handle_error, :api_call_timeout
before_filter :lookup_old_element, :except => [ :history ] before_filter :lookup_old_element, :except => [ :history ]
before_filter :lookup_old_elements_via_current, :only => [ :history ] before_filter :lookup_old_element_versions, :only => [ :history ]
def history def history
# the .where() method used in the lookup_old_element_versions
# call won't throw an error if no records are found, so we have
# to do that ourselves.
raise OSM::APINotFoundError.new if @elements.empty?
doc = OSM::API.new.get_xml_doc doc = OSM::API.new.get_xml_doc
visible_elements = if show_redactions? visible_elements = if show_redactions?

View file

@ -6,8 +6,7 @@ class OldNodeController < OldController
@old_element = OldNode.find([params[:id], params[:version]]) @old_element = OldNode.find([params[:id], params[:version]])
end end
def lookup_old_elements_via_current def lookup_old_element_versions
node = Node.find(params[:id]) @elements = OldNode.where(:node_id => params[:id]).order(:version)
@elements = node.old_nodes
end end
end end

View file

@ -6,8 +6,7 @@ class OldRelationController < OldController
@old_element = OldRelation.find([params[:id], params[:version]]) @old_element = OldRelation.find([params[:id], params[:version]])
end end
def lookup_old_elements_via_current def lookup_old_element_versions
relation = Relation.find(params[:id]) @elements = OldRelation.where(:relation_id => params[:id]).order(:version)
@elements = relation.old_relations
end end
end end

View file

@ -6,8 +6,7 @@ class OldWayController < OldController
@old_element = OldWay.find([params[:id], params[:version]]) @old_element = OldWay.find([params[:id], params[:version]])
end end
def lookup_old_elements_via_current def lookup_old_element_versions
way = Way.find(params[:id]) @elements = OldWay.where(:way_id => params[:id]).order(:version)
@elements = way.old_ways
end end
end end