split_node_tags: Remove old unused files.
This commit is contained in:
parent
4424cd5b94
commit
6c31dbaaec
2 changed files with 0 additions and 92 deletions
|
@ -1,50 +0,0 @@
|
|||
class TempOldNode < ActiveRecord::Base
|
||||
set_table_name 'temp_nodes'
|
||||
|
||||
validates_presence_of :user_id, :timestamp
|
||||
validates_inclusion_of :visible, :in => [ true, false ]
|
||||
validates_numericality_of :latitude, :longitude
|
||||
validate :validate_position
|
||||
|
||||
belongs_to :user
|
||||
|
||||
def validate_position
|
||||
errors.add_to_base("Node is not in the world") unless in_world?
|
||||
end
|
||||
|
||||
def in_world?
|
||||
return true
|
||||
end
|
||||
|
||||
def self.from_node(node)
|
||||
old_node = OldNode.new
|
||||
old_node.latitude = node.latitude
|
||||
old_node.longitude = node.longitude
|
||||
old_node.visible = node.visible
|
||||
old_node.tags = node.tags
|
||||
old_node.timestamp = node.timestamp
|
||||
old_node.user_id = node.user_id
|
||||
old_node.id = node.id
|
||||
return old_node
|
||||
end
|
||||
|
||||
def to_xml_node
|
||||
el1 = XML::Node.new 'node'
|
||||
el1['id'] = self.id.to_s
|
||||
el1['lat'] = self.lat.to_s
|
||||
el1['lon'] = self.lon.to_s
|
||||
el1['user'] = self.user.display_name if self.user.data_public?
|
||||
|
||||
Tags.split(self.tags) do |k,v|
|
||||
el2 = XML::Node.new('tag')
|
||||
el2['k'] = k.to_s
|
||||
el2['v'] = v.to_s
|
||||
el1 << el2
|
||||
end
|
||||
|
||||
el1['visible'] = self.visible.to_s
|
||||
el1['timestamp'] = self.timestamp.xmlschema
|
||||
return el1
|
||||
end
|
||||
|
||||
end
|
|
@ -1,42 +0,0 @@
|
|||
namespace 'db' do
|
||||
desc 'Populate the node_tags table'
|
||||
task :node_tags do
|
||||
require File.dirname(__FILE__) + '/../../config/environment'
|
||||
|
||||
node_count = Node.count
|
||||
limit = 1000 #the number of nodes to grab in one go
|
||||
offset = 0
|
||||
|
||||
while offset < node_count
|
||||
Node.find(:all, :limit => limit, :offset => offset).each do |node|
|
||||
seq_id = 1
|
||||
node.tags.split(';').each do |tag|
|
||||
nt = NodeTag.new
|
||||
nt.id = node.id
|
||||
nt.k = tag.split('=')[0] || ''
|
||||
nt.v = tag.split('=')[1] || ''
|
||||
nt.sequence_id = seq_id
|
||||
nt.save! || raise
|
||||
seq_id += 1
|
||||
end
|
||||
|
||||
version = 1 #version refers to one set of histories
|
||||
node.old_nodes.find(:all, :order => 'timestamp asc').each do |old_node|
|
||||
sequence_id = 1 #sequence_id refers to the sequence of node tags within a history
|
||||
old_node.tags.split(';').each do |tag|
|
||||
ont = OldNodeTag.new
|
||||
ont.id = node.id #the id of the node tag
|
||||
ont.k = tag.split('=')[0] || ''
|
||||
ont.v = tag.split('=')[1] || ''
|
||||
ont.version = version
|
||||
ont.sequence_id = sequence_id
|
||||
ont.save! || raise
|
||||
sequence_id += 1
|
||||
end
|
||||
version += 1
|
||||
end
|
||||
end
|
||||
offset += limit
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue