]> git.openstreetmap.org Git - rails.git/blobdiff - app/controllers/api/notes_controller.rb
Merge remote-tracking branch 'upstream/pull/4209'
[rails.git] / app / controllers / api / notes_controller.rb
index 5e24aa7858ddf1c70b6106baee616a7ce385b1eb..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|
@@ -345,13 +345,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
 
@@ -360,9 +360,9 @@ module Api
     # on their status and the user's request parameters
     def closed_condition(notes)
       closed_since = if params[:closed]
-                       params[:closed].to_i
+                       params[:closed].to_i.days
                      else
-                       7
+                       Note::DEFAULT_FRESHLY_CLOSED_LIMIT
                      end
 
       if closed_since.negative?
@@ -370,7 +370,7 @@ module Api
       elsif closed_since.positive?
         notes.where(:status => "open")
              .or(notes.where(:status => "closed")
-                      .where(notes.arel_table[:closed_at].gt(Time.now.utc - closed_since.days)))
+                      .where(notes.arel_table[:closed_at].gt(Time.now.utc - closed_since)))
       else
         notes.where(:status => "open")
       end