<commit_before>class Scenario < ActiveRecord::Base
  belongs_to :plan
  belongs_to :feature
  has_many :steps, :dependent => :destroy, :order => "position"
  before_create :set_position

  validates_presence_of :name, :plan_id, :feature_id
  self.record_timestamps = false

  named_scope :other_scenarios, lambda {|scenario|
    {:conditions => ["id != ?", scenario.id]}
  }
  named_scope :with_setup, :conditions => ["setup != ''"]
  named_scope :updated_first, :order => "updated_at DESC"
  named_scope :filter, lambda {|value|
    {:conditions => ["name like ? or requirement like ?", "%#{value}%", "%#{value}%"]}
  }

  def setup= new_setup
    self[:setup] = new_setup
    self.updated_at = Time.now
  end

  def self.duplicate(id)
    other_scenario = Scenario.find(id)
    other_scenario.name += " (copy)"
    scenario = Scenario.create(other_scenario.attributes)

    other_scenario.steps.each do |other_step|
      other_step.scenario = scenario
      Step.create(other_step.attributes)
    end
    return scenario
  end

  def copy_setup(other_id)
    other_scenario = Scenario.find(other_id)
    update_attribute(:setup, other_scenario.setup)
  end

  private

  def set_position
    self.position = feature.scenarios.length + 1
    self.updated_at = Time.now
  end
end
<commit_msg>hopefully fix case sensitive postgres problem<commit_after>class Scenario < ActiveRecord::Base
  belongs_to :plan
  belongs_to :feature
  has_many :steps, :dependent => :destroy, :order => "position"
  before_create :set_position

  validates_presence_of :name, :plan_id, :feature_id
  self.record_timestamps = false

  named_scope :other_scenarios, lambda {|scenario|
    {:conditions => ["id != ?", scenario.id]}
  }
  named_scope :with_setup, :conditions => ["setup != ''"]
  named_scope :updated_first, :order => "updated_at DESC"
  named_scope :filter, lambda { |value| 
    if value.nil? then return {} end
    {:conditions => ["lower(name) like ? or lower(requirement) like ?", "%#{value.downcase}%", "%#{value.downcase}%"] }
  }

  def setup= new_setup
    self[:setup] = new_setup
    self.updated_at = Time.now
  end

  def self.duplicate(id)
    other_scenario = Scenario.find(id)
    other_scenario.name += " (copy)"
    scenario = Scenario.create(other_scenario.attributes)

    other_scenario.steps.each do |other_step|
      other_step.scenario = scenario
      Step.create(other_step.attributes)
    end
    return scenario
  end

  def copy_setup(other_id)
    other_scenario = Scenario.find(other_id)
    update_attribute(:setup, other_scenario.setup)
  end

  private

  def set_position
    self.position = feature.scenarios.length + 1
    self.updated_at = Time.now
  end
end

{'fraction_non_alphanumeric': 0.1204460966542751, 'fraction_numerical': 0.0007434944237918215, 'mean_word_length': 4.0018587360594795, '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': '1421302', 'n_tokens_mistral': 908, 'n_tokens_neox': 893, 'n_words': 194}