File tree Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Expand file tree Collapse file tree 2 files changed +25
-0
lines changed Original file line number Diff line number Diff line change 1+ # frozen_string_literal: true
2+
3+ class AddIndexPostLocalePostId < ActiveRecord ::Migration [ 7.2 ]
4+ disable_ddl_transaction!
5+
6+ def up
7+ # clean up invalid index if index creation timeout
8+ execute <<~SQL
9+ DROP INDEX IF EXISTS index_discourse_translator_post_locales_on_post_id
10+ SQL
11+
12+ execute <<~SQL
13+ CREATE UNIQUE INDEX CONCURRENTLY index_discourse_translator_post_locales_on_post_id
14+ ON discourse_translator_post_locales (post_id)
15+ SQL
16+ end
17+
18+ def down
19+ raise ActiveRecord ::IrreversibleMigration
20+ end
21+ end
Original file line number Diff line number Diff line change @@ -31,6 +31,10 @@ module ::DiscourseTranslator
3131 Topic . prepend ( DiscourseTranslator ::Extensions ::TopicExtension )
3232 end
3333
34+ TopicView . on_preload do |topic_view |
35+ topic_view . instance_variable_set ( :@posts , topic_view . posts . includes ( :content_locale ) )
36+ end
37+
3438 add_to_serializer :post , :can_translate do
3539 scope . can_translate? ( object )
3640 end
You can’t perform that action at this time.
0 commit comments