<commit_before># -*- encoding : utf-8 -*-
class ProcessStep < ActiveRecord::Base
  attr_accessible :description, :name, :open_date, :order_number,
                  :consolidated, :consolidated_at

  has_many :feedbacks
  has_and_belongs_to_many :candidates
  belongs_to :selection_process

  scope :consolidated, where(consolidated: true)
  scope :not_consolidated, where(consolidated: false)

  validates_presence_of :description, :name, :open_date, :order_number, :selection_process_id

  def consolidate_step!
    cand_feedback = {}

    candidates.each do |cand|
      unless cand_feedback[cand] = Feedback.where(candidate_id: cand.id, process_step_id: id).first
        raise "Nem todos os candidatos foram avaliados!" 
      end
    end

    self.consolidated = true
    self.consolidated_at = Time.now
    
    cand_feedback.each do |cand, feed|
      FeedbackMailer.send_public_feedback(feed).deliver
    end

    next_step = get_next_step

    if next_step
      next_step.candidates += self.approved_candidates
    end

    self.save
  end

  def get_next_step
    self.selection_process.process_steps.where(order_number: self.order_number + 1).first
  end

  def approved_candidates
    result = []

    candidates.find_each do |cand|
      feedback = Feedback.where(candidate_id: cand.id, process_step_id: id).first
        
      result << cand if feedback.approved?
    end

    result
  end

  def delayed?
    Time.now > consolidated_at
  end

end<commit_msg>Fixing a bug in process_step.delayed?<commit_after># -*- encoding : utf-8 -*-
class ProcessStep < ActiveRecord::Base
  attr_accessible :description, :name, :open_date, :order_number,
                  :consolidated, :consolidated_at

  has_many :feedbacks
  has_and_belongs_to_many :candidates
  belongs_to :selection_process

  scope :consolidated, where(consolidated: true)
  scope :not_consolidated, where(consolidated: false)

  validates_presence_of :description, :name, :open_date, :order_number, :selection_process_id

  def consolidate_step!
    cand_feedback = {}

    candidates.each do |cand|
      unless cand_feedback[cand] = Feedback.where(candidate_id: cand.id, process_step_id: id).first
        raise "Nem todos os candidatos foram avaliados!" 
      end
    end

    self.consolidated = true
    self.consolidated_at = Time.now
    
    cand_feedback.each do |cand, feed|
      FeedbackMailer.send_public_feedback(feed).deliver
    end

    next_step = get_next_step

    if next_step
      next_step.candidates += self.approved_candidates
    end

    self.save
  end

  def get_next_step
    self.selection_process.process_steps.where(order_number: self.order_number + 1).first
  end

  def approved_candidates
    result = []

    candidates.find_each do |cand|
      feedback = Feedback.where(candidate_id: cand.id, process_step_id: id).first
        
      result << cand if feedback.approved?
    end

    result
  end

  def delayed?
    not consolidated and Time.now > consolidated_at
  end

end
{'fraction_non_alphanumeric': 0.08008008008008008, 'fraction_numerical': 0.001334668001334668, 'mean_word_length': 3.3766423357664235, 'pattern_counts': {'":': 0, '<': 9, '<?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': '2729358', 'n_tokens_mistral': 1016, 'n_tokens_neox': 944, 'n_words': 212}