digest suppress tags 사이트 설정에 태그를 추가하고 여러 태그가 있는 주제를 생성하여 로컬 Discourse 사이트에서 문제를 재현할 수 있었습니다.
다음 코드가 문제의 원인입니다: discourse/app/models/topic.rb at main · discourse/discourse · GitHub
if SiteSetting.digest_suppress_tags.present?
tag_ids = Tag.where_name(SiteSetting.digest_suppress_tags.split("|")).pluck(:id)
if tag_ids.present?
topics =
topics.joins("LEFT JOIN topic_tags tg ON topics.id = tg.topic_id").where(
"tg.tag_id NOT IN (?) OR tg.tag_id IS NULL",
tag_ids,
)
end
end
수정: 여기에는 LEFT JOIN이 필요하지 않은 것 같습니다. 조인된 topic_tags 테이블의 컬럼은 메서드 후반부에서 사용되지 않는 것으로 보입니다. 수정 방법은 다음과 같이 간단할 수 있습니다:
if SiteSetting.digest_suppress_tags.present?
tag_ids = Tag.where_name(SiteSetting.digest_suppress_tags.split("|")).pluck(:id)
if tag_ids.present?
topics =
topics.where.not(id: TopicTag.where(tag_id: tag_ids).select(:topic_id))
end
end
최선의 접근 방식은 Discourse 팀이 결정하도록 맡기겠습니다. for_digest 메서드는 매우 자주 실행되므로 효율적이어야 합니다.