- # a=''
- # ActiveRecord::Base.connection.select_values("SELECT segment_id FROM #{db_uqs}").each {|b| a+=b+',' }
- # RAILS_DEFAULT_LOGGER.error("Unique segments are #{a}")
- # a=ActiveRecord::Base.connection.select_value("SELECT #{db_now}")
- # RAILS_DEFAULT_LOGGER.error("Timestamp of this edit is #{a}")
- # RAILS_DEFAULT_LOGGER.error("Userid of this edit is #{uid}")
-
- # delete nodes from uniquesegments (and not in modified way)
-
- sql=<<-EOF
- INSERT INTO nodes (id,latitude,longitude,timestamp,user_id,visible)
- SELECT DISTINCT cn.id,cn.latitude,cn.longitude,#{db_now},#{uid},0
- FROM current_nodes AS cn,
- current_segments AS cs,
- #{db_uqs} AS us
- WHERE(cn.id=cs.node_a OR cn.id=cs.node_b)
- AND cs.id=us.segment_id AND cs.visible=1
- AND (cn.timestamp!=#{db_now} OR cn.user_id!=#{uid})
- EOF
- ActiveRecord::Base.connection.insert(sql)
-
- sql=<<-EOF
- UPDATE current_nodes AS cn,
- current_segments AS cs,
- #{db_uqs} AS us
- SET cn.timestamp=#{db_now},cn.visible=0,cn.user_id=#{uid}
- WHERE (cn.id=cs.node_a OR cn.id=cs.node_b)
- AND cs.id=us.segment_id AND cs.visible=1
- AND (cn.timestamp!=#{db_now} OR cn.user_id!=#{uid})
- EOF
- ActiveRecord::Base.connection.update(sql)
-