@@ -5,7 +5,7 @@ class TopicsController < ApplicationController
55
66 def index
77 @search_query = nil
8- base_query = apply_filters ( Topic . includes ( :creator ) )
8+ base_query = apply_filters ( Topic . includes ( :creator , creator_person : :default_alias , last_sender_person : :default_alias ) )
99
1010 apply_cursor_pagination ( base_query )
1111 preload_topic_participants
@@ -240,7 +240,7 @@ def user_state_frame
240240 return head :unauthorized unless user_signed_in?
241241 return head :ok if topic_ids . empty?
242242
243- @topics = Topic . includes ( :creator ) . where ( id : topic_ids )
243+ @topics = Topic . includes ( :creator , creator_person : :default_alias , last_sender_person : :default_alias ) . where ( id : topic_ids )
244244 preload_topic_states
245245 preload_note_counts
246246 preload_participation_flags
@@ -771,7 +771,7 @@ def filter_team_readers(topic, team_id:)
771771 end
772772
773773 def topics_base_query ( search_query : nil )
774- return apply_filters ( Topic . includes ( :creator ) ) if search_query . nil?
774+ return apply_filters ( Topic . includes ( :creator , creator_person : :default_alias , last_sender_person : :default_alias ) ) if search_query . nil?
775775
776776 cleaned_query = search_query . to_s . strip
777777 return Topic . none if cleaned_query . blank?
@@ -790,7 +790,6 @@ def build_search_query(query)
790790 union_sql = "(#{ title_sql } ) UNION (#{ message_sql } )"
791791
792792 Topic . where ( "topics.id IN (#{ union_sql } )" )
793- . includes ( :creator )
794793 end
795794
796795 def viewing_since_param
@@ -930,7 +929,7 @@ def hydrate_topics_from_entries(entries)
930929 ids = entries . map { |e | e [ :id ] }
931930 return [ ] if ids . empty?
932931
933- topics_map = Topic . includes ( :creator ) . where ( id : ids ) . index_by ( &:id )
932+ topics_map = Topic . includes ( :creator , creator_person : :default_alias , last_sender_person : :default_alias ) . where ( id : ids ) . index_by ( &:id )
934933 entries . filter_map do |entry |
935934 topic = topics_map [ entry [ :id ] ]
936935 next unless topic
0 commit comments