<commit_before>class Support < ActiveRecord::Base

  has_many :comments, dependent: :destroy
  belongs_to :receiver, class_name: 'User'
  belongs_to :user
  belongs_to :topic, counter_cache: true

  scope :done, -> { where(done: true) }
  scope :not_done, -> { where(done: false) }
  default_scope -> { order(updated_at: :desc) }

  def discussed?
    comments_count > 0
  end

  def comments_count
    # TODO: replace with counter cache
    comments.count
  end
end<commit_msg>Added filter scopes in support<commit_after>class Support < ActiveRecord::Base

  has_many :comments, dependent: :destroy
  belongs_to :receiver, class_name: 'User'
  belongs_to :user
  belongs_to :topic, counter_cache: true

  scope :done, -> { where(done: true) }
  scope :not_done, -> { where(done: false) }
  default_scope -> { order(updated_at: :desc) }

  scope :filter_by_topic, -> (topic) { joins(:topic).where(topics: {title: topic} ) }
  scope :filter_by_problem, -> (problem) { where(body: problem) }
  scope :filter_by_receiver, -> (receiver) { joins(:receiver).where(users: {first_name: receiver} ) and joins(:receiver).where(users: {last_name: receiver} ) }
  scope :filter_by_user, -> (user) { joins(:user).where(users: {first_name: user} ) and joins(:user).where(users: {first_name: user} ) }

  def discussed?
    comments_count > 0
  end

  def comments_count
    # TODO: replace with counter cache
    comments.count
  end
end
{'fraction_non_alphanumeric': 0.13000702740688685, 'fraction_numerical': 0.0014054813773717498, 'mean_word_length': 4.414448669201521, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '6304486', 'n_tokens_mistral': 483, 'n_tokens_neox': 470, 'n_words': 120}