]> git.openstreetmap.org Git - rails.git/commitdiff
Make changeset#query preload users, tags and comments
authorTom Hughes <tom@compton.nu>
Mon, 4 Dec 2017 07:54:19 +0000 (07:54 +0000)
committerTom Hughes <tom@compton.nu>
Mon, 4 Dec 2017 07:54:19 +0000 (07:54 +0000)
app/controllers/changeset_controller.rb
app/models/changeset.rb

index 898afae4a30de945a7d5e338c0b4c93b8c8643b1..8fbbe1362605992668f143909d89d88a83f83550 100644 (file)
@@ -216,6 +216,12 @@ class ChangesetController < ApplicationController
     changesets = conditions_closed(changesets, params["closed"])
     changesets = conditions_ids(changesets, params["changesets"])
 
+    # sort and limit the changesets
+    changesets = changesets.order("created_at DESC").limit(100)
+
+    # preload users, tags and comments
+    changesets = changesets.preload(:user, :changeset_tags, :comments)
+
     # create the results document
     results = OSM::API.new.get_xml_doc
 
index 37d26e0a7bf82e1bb911382c82d9be174fa29e47..2ec26ecee2d7612ba0ee5a277c592ffc99a940ee 100644 (file)
@@ -238,7 +238,7 @@ class Changeset < ActiveRecord::Base
 
     bbox.to_unscaled.add_bounds_to(el1, "_") if bbox.complete?
 
-    el1["comments_count"] = comments.count.to_s
+    el1["comments_count"] = comments.length.to_s
 
     if include_discussion
       el2 = XML::Node.new("discussion")