<commit_before>class ProjectSubscriptionJob < Struct.new(:project_subscription_id)

  def perform
    ps = ProjectSubscription.find_by_id(project_subscription_id)
    if ps
      items = all_in_project(ps)
      items.each do |item|
        item.subscriptions.<< Subscription.new(:person => ps.person, :project_subscription_id => project_subscription_id) unless item.subscribed?(ps.person)
      end
    end
  end

  def self.exists? project_subscription_id
    Delayed::Job.find(:first, :conditions => ['handler = ? AND locked_at IS ? AND failed_at IS ?', ProjectSubscriptionJob.new(project_subscription_id).to_yaml, nil, nil]) != nil
  end

  def self.create_job project_subscription_id, t=15.seconds.from_now, priority=0
    Delayed::Job.enqueue(ProjectSubscriptionJob.new(project_subscription_id), priority, t) unless exists? project_subscription_id
  end

  def all_in_project project_subscription
    all = project_subscription.subscribable_types.map(&:constantize).collect do |klass|
      if klass.reflect_on_association(:projects)
        klass.scoped(:include => :projects)
      else
        klass.all
      end
    end.flatten
    all.select {|item| item.projects.include? project_subscription.project}
  end
end<commit_msg>removed unwanted '.'<commit_after>class ProjectSubscriptionJob < Struct.new(:project_subscription_id)

  def perform
    ps = ProjectSubscription.find_by_id(project_subscription_id)
    if ps
      items = all_in_project(ps)
      items.each do |item|
        item.subscriptions << Subscription.new(:person => ps.person, :project_subscription_id => project_subscription_id) unless item.subscribed?(ps.person)
      end
    end
  end

  def self.exists? project_subscription_id
    Delayed::Job.find(:first, :conditions => ['handler = ? AND locked_at IS ? AND failed_at IS ?', ProjectSubscriptionJob.new(project_subscription_id).to_yaml, nil, nil]) != nil
  end

  def self.create_job project_subscription_id, t=15.seconds.from_now, priority=0
    Delayed::Job.enqueue(ProjectSubscriptionJob.new(project_subscription_id), priority, t) unless exists? project_subscription_id
  end

  def all_in_project project_subscription
    all = project_subscription.subscribable_types.map(&:constantize).collect do |klass|
      if klass.reflect_on_association(:projects)
        klass.scoped(:include => :projects)
      else
        klass.all
      end
    end.flatten
    all.select {|item| item.projects.include? project_subscription.project}
  end
end
{'fraction_non_alphanumeric': 0.09519967728922953, 'fraction_numerical': 0.0024203307785397336, 'mean_word_length': 4.414847161572053, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 11, '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': '4721865', 'n_tokens_mistral': 736, 'n_tokens_neox': 763, 'n_words': 149}