DEV: reindex old data in a more consistent way

DEV: reindex old data in a more consistent way

Previously we were grabbing arbitrary rows in many cases which makes diagnosing issues in the indexer more complex

diff --git a/app/jobs/scheduled/reindex_search.rb b/app/jobs/scheduled/reindex_search.rb
index 90f6a34..6d3b431 100644
--- a/app/jobs/scheduled/reindex_search.rb
+++ b/app/jobs/scheduled/reindex_search.rb
@@ -126,6 +126,7 @@ module Jobs
       Category.joins(:category_search_data)
         .where('category_search_data.locale != ?
                 OR category_search_data.version != ?', SiteSetting.default_locale, SearchIndexer::INDEX_VERSION)
+        .order('categories.id asc')
         .limit(limit)
         .pluck(:id)
     end
@@ -134,6 +135,7 @@ module Jobs
       Topic.joins(:topic_search_data)
         .where('topic_search_data.locale != ?
                 OR topic_search_data.version != ?', SiteSetting.default_locale, SearchIndexer::INDEX_VERSION)
+        .order('topics.id desc')
         .limit(limit)
         .pluck(:id)
     end
@@ -142,6 +144,7 @@ module Jobs
       User.joins(:user_search_data)
         .where('user_search_data.locale != ?
                 OR user_search_data.version != ?', SiteSetting.default_locale, SearchIndexer::INDEX_VERSION)
+        .order('users.id asc')
         .limit(limit)
         .pluck(:id)
     end
@@ -150,6 +153,7 @@ module Jobs
       Tag.joins(:tag_search_data)
         .where('tag_search_data.locale != ?
                 OR tag_search_data.version != ?', SiteSetting.default_locale, SearchIndexer::INDEX_VERSION)
+        .order('tags.id asc')
         .limit(limit)
         .pluck(:id)
     end

GitHub sha: 77300c1d

1 Like