belongs_to :user
- has_many :changeset_tags, :foreign_key => 'id'
+ has_many :changeset_tags
has_many :nodes
has_many :ways
validates_numericality_of :user_id, :integer_only => true
validates_numericality_of :num_changes, :integer_only => true, :greater_than_or_equal_to => 0
+ before_save :update_closed_at
+
# over-expansion factor to use when updating the bounding box
EXPAND = 0.1
def self.from_xml(xml, create=false)
begin
- p = XML::Parser.string(xml)
+ p = XML::Parser.string(xml, :options => XML::Parser::Options::NOERROR)
doc = p.parse
doc.find('//osm/changeset').each do |pt|
self.save!
tags = self.tags
- ChangesetTag.delete_all(['id = ?', self.id])
+ ChangesetTag.delete_all(:changeset_id => self.id)
tags.each do |k,v|
tag = ChangesetTag.new
+ tag.changeset_id = self.id
tag.k = k
tag.v = v
- tag.id = self.id
tag.save!
end
end
# set the auto-close time to be one hour in the future unless
# that would make it more than 24h long, in which case clip to
# 24h, as this has been decided is a reasonable time limit.
- def before_save
+ def update_closed_at
if self.is_open?
if (closed_at - created_at) > (MAX_TIME_OPEN - IDLE_TIMEOUT)
self.closed_at = created_at + MAX_TIME_OPEN