]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/api/notes_controller.rb
Add some additional preloads to notes#feed
[rails.git] / app / controllers / api / notes_controller.rb
index 5e24532e79bf7f31594a82db9143465aa502dcbf..c489f96be43964640adff2446b154b06e46c6fa2 100644 (file)
@@ -251,7 +251,9 @@ 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(:author, :note => { :comments => :author })
 
       # Render the result
       respond_to do |format|
@@ -345,13 +347,13 @@ module Api
     # Get the maximum number of results to return
     def result_limit
       if params[:limit]
-        if params[:limit].to_i.positive? && params[:limit].to_i <= 10000
+        if params[:limit].to_i.positive? && params[:limit].to_i <= Settings.max_note_query_limit
           params[:limit].to_i
         else
-          raise OSM::APIBadUserInput, "Note limit must be between 1 and 10000"
+          raise OSM::APIBadUserInput, "Note limit must be between 1 and #{Settings.max_note_query_limit}"
         end
       else
-        100
+        Settings.default_note_query_limit
       end
     end