PERF: optimize translation progress dashboard with batch query (#34861)

Replace individual per-locale queries with a single query that
calculates completion progress for all locales at once.

This commit also removes methods off the `base_candidate` (used for
Categories and Topics as well) which are not used any more, as the
progress dashboard only shows progress for posts.

t/162846/4

---------

Co-authored-by: Nat <natalie.tay@discourse.org>
This commit is contained in:
Rafael dos Santos Silva
2025-09-29 13:32:40 +08:00
committed by GitHub
co-authored by Nat
parent 4bc7abbb04
commit a40149bd1b
11 changed files with 184 additions and 185 deletions
@@ -0,0 +1,13 @@
# frozen_string_literal: true
class AddIndexToPostsLocale < ActiveRecord::Migration[8.0]
disable_ddl_transaction!
def up
remove_index :posts, :locale, algorithm: :concurrently, if_exists: true
add_index :posts, :locale, algorithm: :concurrently
end
def down
remove_index :posts, :locale, algorithm: :concurrently, if_exists: true
end
end