From 4e082c73902717290f1ef1683d7075a70995ff23 Mon Sep 17 00:00:00 2001 From: David Taylor Date: Thu, 21 Mar 2024 13:19:53 +0000 Subject: [PATCH] FIX: Ensure sitemaps include all topics with no duplicates (#26289) We were using `OFFSET`/`LIMIT` to query topics without an 'ORDER'. Without an explicit order, postgres makes no guarantees about which rows will be returned for each query. This commit adds `ORDER BY id ASC` so that our sitemaps behave consistently. --- app/models/sitemap.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/sitemap.rb b/app/models/sitemap.rb index a0ca9a6df26..a051c4885fe 100644 --- a/app/models/sitemap.rb +++ b/app/models/sitemap.rb @@ -62,7 +62,7 @@ class Sitemap < ActiveRecord::Base else offset = (name.to_i - 1) * max_page_size - indexable_topics.limit(max_page_size).offset(offset) + indexable_topics.order(id: :asc).limit(max_page_size).offset(offset) end end end