]> git.openstreetmap.org Git - rails.git/commitdiff
Merge remote-tracking branch 'upstream/pull/4210'
authorTom Hughes <tom@compton.nu>
Wed, 30 Aug 2023 17:10:20 +0000 (18:10 +0100)
committerTom Hughes <tom@compton.nu>
Wed, 30 Aug 2023 17:10:20 +0000 (18:10 +0100)
app/controllers/api/changesets_controller.rb
app/controllers/api/notes_controller.rb
app/controllers/changesets_controller.rb
app/controllers/diary_entries_controller.rb
app/controllers/issues_controller.rb
app/controllers/user_roles_controller.rb
app/models/changeset.rb
app/models/trace.rb
test/controllers/diary_entries_controller_test.rb
test/models/trace_test.rb

index a3dff4f1cd7e4fc935986a009c71e9b31ac7c411..7bb7a5a4de14bddb49f988f7f9285d96de074b1e 100644 (file)
@@ -325,7 +325,7 @@ module Api
           raise OSM::APINotFoundError if current_user.nil? || current_user != u
         end
 
-        changesets.where(:user_id => u.id)
+        changesets.where(:user => u)
       end
     end
 
index 83024288db43d9963249c301faca3180f457fce8..e6f391ede96e3767e7c5c08f9c210e3a744a9f8c 100644 (file)
@@ -251,7 +251,7 @@ module Api
       end
 
       # Find the comments we want to return
-      @comments = NoteComment.where(:note_id => notes).order("created_at DESC").limit(result_limit).preload(:note)
+      @comments = NoteComment.where(:note => notes).order("created_at DESC").limit(result_limit).preload(:note)
 
       # Render the result
       respond_to do |format|
index 22d3356b79fee7425865fcff5de6098b2cc0b153..fef4d85eb51273596dfe81ccfc0cad88ba81c19f 100644 (file)
@@ -48,16 +48,16 @@ class ChangesetsController < ApplicationController
 
       if @params[:display_name]
         changesets = if user.data_public? || user == current_user
-                       changesets.where(:user_id => user.id)
+                       changesets.where(:user => user)
                      else
                        changesets.where("false")
                      end
       elsif @params[:bbox]
         changesets = conditions_bbox(changesets, BoundingBox.from_bbox_params(params))
       elsif @params[:friends] && current_user
-        changesets = changesets.where(:user_id => current_user.friends.identifiable)
+        changesets = changesets.where(:user => current_user.friends.identifiable)
       elsif @params[:nearby] && current_user
-        changesets = changesets.where(:user_id => current_user.nearby)
+        changesets = changesets.where(:user => current_user.nearby)
       end
 
       changesets = changesets.where("changesets.id <= ?", @params[:max_id]) if @params[:max_id]
index ea6d1d27601db89980fa6366308b90a5ad996f45..dcb625d836932a9746e2aac99bc5d2952577ae92 100644 (file)
@@ -27,7 +27,7 @@ class DiaryEntriesController < ApplicationController
     elsif params[:friends]
       if current_user
         @title = t ".title_friends"
-        entries = DiaryEntry.where(:user_id => current_user.friends)
+        entries = DiaryEntry.where(:user => current_user.friends)
       else
         require_user
         return
@@ -35,7 +35,7 @@ class DiaryEntriesController < ApplicationController
     elsif params[:nearby]
       if current_user
         @title = t ".title_nearby"
-        entries = DiaryEntry.where(:user_id => current_user.nearby)
+        entries = DiaryEntry.where(:user => current_user.nearby)
       else
         require_user
         return
index 88c7a46acd5f0bb3859f9e1dce567815d4328fd9..c24054f77ff3adf4ab44073cea134c9748403b51 100644 (file)
@@ -24,7 +24,7 @@ class IssuesController < ApplicationController
     if params[:search_by_user].present?
       @find_user = User.find_by(:display_name => params[:search_by_user])
       if @find_user
-        @issues = @issues.where(:reported_user_id => @find_user.id)
+        @issues = @issues.where(:reported_user => @find_user)
       else
         @issues = @issues.none
         flash.now[:warning] = t(".user_not_found")
index b54cd0bd7a3eee82ccfecb01ce14882ba1d7c3cc..469b2c40b626845191e7a5265e873c340da7c4f4 100644 (file)
@@ -22,7 +22,7 @@ class UserRolesController < ApplicationController
     if current_user == @user && @role == "administrator"
       flash[:error] = t("user_role.filter.not_revoke_admin_current_user")
     else
-      UserRole.where(:user_id => @user.id, :role => @role).delete_all
+      UserRole.where(:user => @user, :role => @role).delete_all
     end
     redirect_to user_path(@user)
   end
index f23a4e356e883bd51f0fb0d01cb52897a75fd0ab..ce09438245844be0ff4ba241818973cdf26b5bab 100644 (file)
@@ -170,7 +170,7 @@ class Changeset < ApplicationRecord
       save!
 
       tags = self.tags
-      ChangesetTag.where(:changeset_id => id).delete_all
+      ChangesetTag.where(:changeset => id).delete_all
 
       tags.each do |k, v|
         tag = ChangesetTag.new
index 35fee0bf4f800d7fd22f906d1b9cc3040ea5727f..2411fb9b7a3c56c2f2adc57787a6194f83058c51 100644 (file)
@@ -209,7 +209,7 @@ class Trace < ApplicationRecord
       first = true
 
       # If there are any existing points for this trace then delete them
-      Tracepoint.where(:gpx_id => id).delete_all
+      Tracepoint.where(:trace => id).delete_all
 
       gpx.points.each_slice(1_000) do |points|
         # Gather the trace points together for a bulk import
@@ -242,10 +242,10 @@ class Trace < ApplicationRecord
       end
 
       if gpx.actual_points.positive?
-        max_lat = Tracepoint.where(:gpx_id => id).maximum(:latitude)
-        min_lat = Tracepoint.where(:gpx_id => id).minimum(:latitude)
-        max_lon = Tracepoint.where(:gpx_id => id).maximum(:longitude)
-        min_lon = Tracepoint.where(:gpx_id => id).minimum(:longitude)
+        max_lat = Tracepoint.where(:trace => id).maximum(:latitude)
+        min_lat = Tracepoint.where(:trace => id).minimum(:latitude)
+        max_lon = Tracepoint.where(:trace => id).maximum(:longitude)
+        min_lon = Tracepoint.where(:trace => id).minimum(:longitude)
 
         max_lat = max_lat.to_f / 10000000
         min_lat = min_lat.to_f / 10000000
index 6365d46e5de0aba5210c181131194d15dde78ca7..ea918cb6bbd765b577d6460901cebba1b9985e71 100644 (file)
@@ -164,7 +164,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest
     assert_response :success
     assert_template :new
 
-    assert_nil UserPreference.where(:user_id => user.id, :k => "diary.default_language").first
+    assert_nil UserPreference.where(:user => user, :k => "diary.default_language").first
   end
 
   def test_create
@@ -189,7 +189,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest
     # checks if user was subscribed
     assert_equal 1, entry.subscribers.length
 
-    assert_equal "en", UserPreference.where(:user_id => user.id, :k => "diary.default_language").first.v
+    assert_equal "en", UserPreference.where(:user => user, :k => "diary.default_language").first.v
   end
 
   def test_create_german
@@ -216,7 +216,7 @@ class DiaryEntriesControllerTest < ActionDispatch::IntegrationTest
     # checks if user was subscribed
     assert_equal 1, entry.subscribers.length
 
-    assert_equal "de", UserPreference.where(:user_id => user.id, :k => "diary.default_language").first.v
+    assert_equal "de", UserPreference.where(:user => user, :k => "diary.default_language").first.v
   end
 
   def test_new_spammy
index 762df66484d185c82bc52f305e739a989421a1cc..66107771ae5a299c7155e0097add0ed06e8800cb 100644 (file)
@@ -193,16 +193,16 @@ class TraceTest < ActiveSupport::TestCase
 
   def test_import_creates_tracepoints
     trace = create(:trace, :fixture => "a")
-    assert_equal 0, Tracepoint.where(:gpx_id => trace.id).count
+    assert_equal 0, Tracepoint.where(:trace => trace).count
 
     trace.import
 
     trace.reload
-    assert_equal 1, Tracepoint.where(:gpx_id => trace.id).count
+    assert_equal 1, Tracepoint.where(:trace => trace).count
 
     # Check that the tile has been set prior to the bulk import
     # i.e. that the callbacks have been run correctly
-    assert_equal 3221331576, Tracepoint.where(:gpx_id => trace.id).first.tile
+    assert_equal 3221331576, Tracepoint.where(:trace => trace).first.tile
   end
 
   def test_import_creates_icon