Use `bumped_at` instead of `last_posted_at` (#13)

Use bumped_at instead of last_posted_at (#13)

This will catch edits to the last post.

diff --git a/app/models/sitemap.rb b/app/models/sitemap.rb
index 68b477e..b7b865d 100644
--- a/app/models/sitemap.rb
+++ b/app/models/sitemap.rb
@@ -8,7 +8,7 @@ class Sitemap < ActiveRecord::Base
     query = self.name == RECENT_SITEMAP_NAME ? Sitemap.topics_query : Sitemap.topics_query_by_page(name.to_i)
 
     self.update!(
-      last_posted_at: query.maximum(:last_posted_at) || query.maximum(:updated_at) || 3.days.ago,
+      last_posted_at: query.maximum(:bumped_at) || query.maximum(:updated_at) || 3.days.ago,
       enabled: true
     )
   end
@@ -33,10 +33,10 @@ class Sitemap < ActiveRecord::Base
     category_ids = Category.where(read_restricted: false).pluck(:id)
     query = Topic.where(category_id: category_ids, visible: true)
     if since
-      query = query.where('last_posted_at > ?', since)
-      query = query.order(last_posted_at: :desc)
+      query = query.where('bumped_at > ?', since)
+      query = query.order(bumped_at: :desc)
     else
-      query = query.order(last_posted_at: :asc)
+      query = query.order(bumped_at: :asc)
     end
     query
   end
diff --git a/plugin.rb b/plugin.rb
index e5fff6c..dbc628d 100644
--- a/plugin.rb
+++ b/plugin.rb
@@ -48,7 +48,7 @@ after_initialize do
       raise Discourse::NotFound if sitemap.blank?
 
       @output = Rails.cache.fetch("sitemap/#{index}/#{Sitemap.size}", expires_in: 24.hours) do
-        @topics = Sitemap.topics_query_by_page(index.to_i).pluck(:id, :slug, :last_posted_at, :updated_at).to_a
+        @topics = Sitemap.topics_query_by_page(index.to_i).pluck(:id, :slug, :bumped_at, :updated_at).to_a
         render :default, content_type: 'text/xml; charset=UTF-8'
       end
       render plain: @output, content_type: 'text/xml; charset=UTF-8' unless performed?
@@ -60,7 +60,7 @@ after_initialize do
       sitemap.update_last_posted_at!
 
       @output = Rails.cache.fetch("sitemap/recent/#{sitemap.last_posted_at.to_i}", expires_in: 1.hour) do
-        @topics = Sitemap.topics_query(3.days.ago).limit(Sitemap.size).pluck(:id, :slug, :last_posted_at, :updated_at, :posts_count).to_a
+        @topics = Sitemap.topics_query(3.days.ago).limit(Sitemap.size).pluck(:id, :slug, :bumped_at, :updated_at, :posts_count).to_a
         render :default, content_type: 'text/xml; charset=UTF-8'
       end
       render plain: @output, content_type: 'text/xml; charset=UTF-8' unless performed?

GitHub sha: 75b47650

This commit appears in #13 which was approved by pmusaraj. It was merged by eviltrout.