Skip to content

Commit

Permalink
Fix new rubocop warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
tomhughes committed Sep 7, 2020
1 parent feb1412 commit 18b9b9f
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
10 changes: 5 additions & 5 deletions app/controllers/api/amf_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -904,7 +904,7 @@ def strip_non_xml_chars(tags)
# Alternative SQL queries for getway/whichways

def sql_find_ways_in_area(bbox)
sql = <<~SQL
sql = <<~SQL.squish
SELECT DISTINCT current_ways.id AS wayid,current_ways.version AS version
FROM current_way_nodes
INNER JOIN current_nodes ON current_nodes.id=current_way_nodes.node_id
Expand All @@ -918,7 +918,7 @@ def sql_find_ways_in_area(bbox)

def sql_find_pois_in_area(bbox)
pois = []
sql = <<~SQL
sql = <<~SQL.squish
SELECT current_nodes.id,current_nodes.latitude*0.0000001 AS lat,current_nodes.longitude*0.0000001 AS lon,current_nodes.version
FROM current_nodes
LEFT OUTER JOIN current_way_nodes cwn ON cwn.node_id=current_nodes.id
Expand All @@ -939,15 +939,15 @@ def sql_find_pois_in_area(bbox)
def sql_find_relations_in_area_and_ways(bbox, way_ids)
# ** It would be more Potlatchy to get relations for nodes within ways
# during 'getway', not here
sql = <<~SQL
sql = <<~SQL.squish
SELECT DISTINCT cr.id AS relid,cr.version AS version
FROM current_relations cr
INNER JOIN current_relation_members crm ON crm.id=cr.id
INNER JOIN current_nodes cn ON crm.member_id=cn.id AND crm.member_type='Node'
WHERE #{OSM.sql_for_area(bbox, 'cn.')}
SQL
unless way_ids.empty?
sql += <<~SQL
sql += <<~SQL.squish
UNION
SELECT DISTINCT cr.id AS relid,cr.version AS version
FROM current_relations cr
Expand All @@ -961,7 +961,7 @@ def sql_find_relations_in_area_and_ways(bbox, way_ids)

def sql_get_nodes_in_way(wayid)
points = []
sql = <<~SQL
sql = <<~SQL.squish
SELECT latitude*0.0000001 AS lat,longitude*0.0000001 AS lon,current_nodes.id,current_nodes.version
FROM current_way_nodes,current_nodes
WHERE current_way_nodes.id=#{wayid.to_i}
Expand Down
2 changes: 1 addition & 1 deletion app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ def nearby(radius = Settings.nearby_radius, num = Settings.nearby_users)
sql_for_area = QuadTile.sql_for_area(gc.bounds(radius), "home_")
sql_for_distance = gc.sql_for_distance("home_lat", "home_lon")
nearby = User.active.identifiable
.where("id != ?", id)
.where.not(:id => id)
.where(sql_for_area)
.where("#{sql_for_distance} <= ?", radius)
.order(Arel.sql(sql_for_distance))
Expand Down
2 changes: 1 addition & 1 deletion db/migrate/004_user_enhancements.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def self.up
add_index "user_tokens", ["token"], :name => "user_tokens_token_idx", :unique => true
add_index "user_tokens", ["user_id"], :name => "user_tokens_user_id_idx"

User.where("token is not null").each do |user|
User.where.not(:token => nil).each do |user|
UserToken.create(:user_id => user.id, :token => user.token, :expiry => 1.week.from_now)
end

Expand Down
6 changes: 3 additions & 3 deletions db/migrate/006_tile_nodes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class OldNode < ApplicationRecord

def self.upgrade_table(from_table, to_table, model)
if ENV["USE_DB_FUNCTIONS"]
execute <<-SQL
execute <<-SQL.squish
INSERT INTO #{to_table} (id, latitude, longitude, user_id, visible, tags, timestamp, tile)
SELECT id, ROUND(latitude * 10000000), ROUND(longitude * 10000000),
user_id, visible, tags, timestamp,
Expand All @@ -20,7 +20,7 @@ def self.upgrade_table(from_table, to_table, model)
FROM #{from_table}
SQL
else
execute <<-SQL
execute <<-SQL.squish
INSERT INTO #{to_table} (id, latitude, longitude, user_id, visible, tags, timestamp, tile)
SELECT id, ROUND(latitude * 10000000), ROUND(longitude * 10000000),
user_id, visible, tags, timestamp, 0
Expand All @@ -32,7 +32,7 @@ def self.upgrade_table(from_table, to_table, model)
end

def self.downgrade_table(from_table, to_table)
execute <<-SQL
execute <<-SQL.squish
INSERT INTO #{to_table} (id, latitude, longitude, user_id, visible, tags, timestamp)
SELECT id, latitude / 10000000, longitude / 10000000,
user_id, visible, tags, timestamp
Expand Down

0 comments on commit 18b9b9f

Please sign in to comment.