<commit_before># frozen_string_literal: true

# A comment and its replies. The first comment in a thread is displayed as a
# “post,” with more room for detail.
#
# @attr original_highlight_text [String] the string of text from the thread’s
#   {Card} to which it is attached. The first of any duplicate matches will be
#   used, so it is intended to be a unique string within the card.
# @attr locale [Iso639_1Code] which translation of the case this comment thread
#   is attached to.
class CommentThread < ApplicationRecord
  belongs_to :card, touch: true, optional: true
  belongs_to :forum, touch: true
  belongs_to :reader

  has_many :comments, dependent: :destroy

  # The comment threads that are visible to a given reader
  # @return [ActiveRecord::Relation<CommentThread>]
  def self.visible_to_reader(r)
    where(locale: I18n.locale.to_s)
      .where('comment_threads.comments_count > 0 OR
      comment_threads.reader_id = ?',
             r.id)
  end

  # The reader participants in this comment thread
  # @return [Array<Reader>]
  def collocutors
    comments.map(&:reader).uniq
  end
end<commit_msg>fix: don’t limit comment visibility based on locale<commit_after># frozen_string_literal: true

# A comment and its replies. The first comment in a thread is displayed as a
# “post,” with more room for detail.
#
# @attr original_highlight_text [String] the string of text from the thread’s
#   {Card} to which it is attached. The first of any duplicate matches will be
#   used, so it is intended to be a unique string within the card.
# @attr locale [Iso639_1Code] which translation of the case this comment thread
#   is attached to.
class CommentThread < ApplicationRecord
  belongs_to :card, touch: true, optional: true
  belongs_to :forum, touch: true
  belongs_to :reader

  has_many :comments, dependent: :destroy

  # The comment threads that are visible to a given reader
  # @return [ActiveRecord::Relation<CommentThread>]
  def self.visible_to_reader(reader)
    where(
      'comment_threads.comments_count > 0 OR comment_threads.reader_id = ?',
      reader.id
    )
  end

  # The reader participants in this comment thread
  # @return [Array<Reader>]
  def collocutors
    comments.map(&:reader).uniq
  end
end
{'fraction_non_alphanumeric': 0.07582515611061552, 'fraction_numerical': 0.0053523639607493305, 'mean_word_length': 4.006696428571429, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3801175', 'n_tokens_mistral': 666, 'n_tokens_neox': 646, 'n_words': 265}