<commit_before>class Category < ActiveRecord::Base
  has_notifications
  has_many :projects
  has_many :category_followers
  has_many :users, through: :category_followers

  validates_presence_of :name_pt
  validates_uniqueness_of :name_pt

  scope :with_projects_on_this_week, -> {
    joins(:projects).merge(Project.of_current_week)
  }

  def self.with_projects
    where("exists(select true from projects p where p.category_id = categories.id and p.state not in('draft', 'rejected'))")
  end

  def self.array
    order('name_'+ I18n.locale.to_s + ' ASC').collect { |c| [c.send('name_' + I18n.locale.to_s), c.id] }
  end

  def to_s
    self.send('name_' + I18n.locale.to_s)
  end

  def total_online_projects
    self.projects.with_state('online').count
  end
end
<commit_msg>method to deliver the notification of projects of the week<commit_after>class Category < ActiveRecord::Base
  has_notifications
  has_many :projects
  has_many :category_followers
  has_many :users, through: :category_followers

  validates_presence_of :name_pt
  validates_uniqueness_of :name_pt

  scope :with_projects_on_this_week, -> {
    joins(:projects).merge(Project.of_current_week)
  }

  def self.with_projects
    where("exists(select true from projects p where p.category_id = categories.id and p.state not in('draft', 'rejected'))")
  end

  def self.array
    order('name_'+ I18n.locale.to_s + ' ASC').collect { |c| [c.send('name_' + I18n.locale.to_s), c.id] }
  end

  def to_s
    self.send('name_' + I18n.locale.to_s)
  end

  def total_online_projects
    self.projects.with_state('online').count
  end

  def deliver_projects_of_week_notification
    self.users.that_dont_receive_categoried_notifications_for(self.id).each do |user|
      self.notify(:categorized_projects_of_the_week, user, self)
    end
  end
end

{'fraction_non_alphanumeric': 0.10456796917996698, 'fraction_numerical': 0.006604292790313704, 'mean_word_length': 4.4431137724550895, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '732368', 'n_tokens_mistral': 655, 'n_tokens_neox': 634, 'n_words': 129}