- if self.is_open?
- if (closed_at - created_at) > (MAX_TIME_OPEN - IDLE_TIMEOUT)
- self.closed_at = created_at + MAX_TIME_OPEN
- else
- self.closed_at = Time.now.getutc + IDLE_TIMEOUT
- end
- end
- end
-
- def to_xml(include_discussion = false)
- doc = OSM::API.new.get_xml_doc
- doc.root << to_xml_node(nil, include_discussion)
- doc
- end
-
- def to_xml_node(user_display_name_cache = nil, include_discussion = false)
- el1 = XML::Node.new 'changeset'
- el1['id'] = id.to_s
-
- user_display_name_cache = {} if user_display_name_cache.nil?
-
- if user_display_name_cache && user_display_name_cache.key?(user_id)
- # use the cache if available
- elsif user.data_public?
- user_display_name_cache[user_id] = user.display_name
- else
- user_display_name_cache[user_id] = nil
- end
-
- el1['user'] = user_display_name_cache[user_id] unless user_display_name_cache[user_id].nil?
- el1['uid'] = user_id.to_s if user.data_public?
-
- tags.each do |k, v|
- el2 = XML::Node.new('tag')
- el2['k'] = k.to_s
- el2['v'] = v.to_s
- el1 << el2
+ if open?
+ self.closed_at = if (closed_at - created_at) > (MAX_TIME_OPEN - IDLE_TIMEOUT)
+ created_at + MAX_TIME_OPEN
+ else
+ Time.now.utc + IDLE_TIMEOUT
+ end