<commit_before># encoding: UTF-8
class TimeRange < ActiveRecord::Base
  validates_presence_of :name
  validates_uniqueness_of :name

  # Returns the current start time (based on the ruby in
  # the start column)
  def start_time
    eval(start) if start.present?
  end

  # Returns the current end time (based on the ruby in
  # the end column)
  def end_time
    eval(self.end) if self.end.present?
  end

  def to_s
    name
  end

  DEFAULTS = [
              [ I18n.t('time.today'), { :start => "Date.today", :end => "Date.tomorrow" } ],
              [ I18n.t('time.tomorrow'), { :start => "Date.tomorrow", :end => "Date.tomorrow + 1.day" } ],
              [ I18n.t('time.yesterday'), { :start => "Date.yesterday", :end => "Date.today" } ],
              [ I18n.t('time.this_week'), { :start => "Date.today.at_beginning_of_week", :end => "Date.today.at_end_of_week" } ],
              [ I18n.t('time.next_week'), { :start => "Date.today.at_beginning_of_week + 7", :end => "Date.today.at_beginning_of_week + 14" } ],
              [ I18n.t('time.in_the_past'), { :start => "Time.utc(1000)", :end => "Date.today" } ],
              [ I18n.t('time.in_the_future'), { :start => "Date.tomorrow", :end => "TIme.utc(2100)" } ],
              [ I18n.t('time.last_week'), { :start => "Date.today.at_beginning_of_week - 7", :end => "Date.today.at_beginning_of_week" } ],
              [ I18n.t('time.this_month'), { :start => "Date.today.at_beginning_of_month", :end => "Date.today.at_end_of_month" } ],
              [ I18n.t('time.last_month'), { :start => "(Date.today.at_beginning_of_month - 10.days).at_beginning_of_month", :end => "Date.today.at_beginning_of_month" } ],
              [ I18n.t('time.this_year'), { :start => "Date.today.at_beginning_of_year", :end => "Date.today.at_end_of_year" } ],
              [ I18n.t('time.last_year'), { :start => "(Date.today.at_beginning_of_year - 10.days).at_beginning_of_year", :end => "(Date.today.at_beginning_of_year - 10.days).at_end_of_year" } ],
              [ I18n.t('time.yesterday_or_earlier'), { :start => "Time.utc(1000)", :end => "Date.yesterday" } ],
              [ I18n.t('time.yesterday_or_later'), { :start => "Date.yesterday", :end => "Time.utc(2100)" } ],
              [ I18n.t('time.tomorrow_or_earlier'), { :start => "Time.utc(1000)", :end => "Date.tomorrow" } ],
              [ I18n.t('time.tomorrow_or_later'), { :start => "Date.tomorrow", :end => "Time.utc(2100)" } ],
              [ I18n.t('time.today_or_later'), { :start => "Date.today", :end => "Time.utc(2100)" } ],
              [ I18n.t('time.today_or_earlier'), { :start => "Time.utc(1000)", :end => "Date.today" } ]
             ]

  FUTURE_KEYWORDS_LIST = [I18n.t('time.today_or_later'),I18n.t('time.tomorrow_or_later'),
                          I18n.t('time.yesterday_or_later'),I18n.t('time.in_the_future'),
                          I18n.t('time.yesterday_or_later'), I18n.t('time.tomorrow'),
                          I18n.t('time.tomorrow_or_earlier')]

  # Updates or creates the default time ranges
  def self.create_defaults
    DEFAULTS.each do |name, attrs|
      TimeRange.find_or_create_by_name(name).update_attributes(attrs)
    end
  end

  def TimeRange.end_time(name)
    eval(RANGES[name][1])
  end
  def TimeRange.start_time(name)
    eval(RANGES[name][0])
  end

  def self.keyword_in_future? (keyword)
    FUTURE_KEYWORDS_LIST.each do |name|
      if (name == keyword.to_s)
        return true
      end
    end
    return false<commit_msg>Removed 'next week' from created at and updated at.<commit_after># encoding: UTF-8
class TimeRange < ActiveRecord::Base
  validates_presence_of :name
  validates_uniqueness_of :name

  # Returns the current start time (based on the ruby in
  # the start column)
  def start_time
    eval(start) if start.present?
  end

  # Returns the current end time (based on the ruby in
  # the end column)
  def end_time
    eval(self.end) if self.end.present?
  end

  def to_s
    name
  end

  DEFAULTS = [
              [ I18n.t('time.today'), { :start => "Date.today", :end => "Date.tomorrow" } ],
              [ I18n.t('time.tomorrow'), { :start => "Date.tomorrow", :end => "Date.tomorrow + 1.day" } ],
              [ I18n.t('time.yesterday'), { :start => "Date.yesterday", :end => "Date.today" } ],
              [ I18n.t('time.this_week'), { :start => "Date.today.at_beginning_of_week", :end => "Date.today.at_end_of_week" } ],
              [ I18n.t('time.next_week'), { :start => "Date.today.at_beginning_of_week + 7", :end => "Date.today.at_beginning_of_week + 14" } ],
              [ I18n.t('time.in_the_past'), { :start => "Time.utc(1000)", :end => "Date.today" } ],
              [ I18n.t('time.in_the_future'), { :start => "Date.tomorrow", :end => "TIme.utc(2100)" } ],
              [ I18n.t('time.last_week'), { :start => "Date.today.at_beginning_of_week - 7", :end => "Date.today.at_beginning_of_week" } ],
              [ I18n.t('time.this_month'), { :start => "Date.today.at_beginning_of_month", :end => "Date.today.at_end_of_month" } ],
              [ I18n.t('time.last_month'), { :start => "(Date.today.at_beginning_of_month - 10.days).at_beginning_of_month", :end => "Date.today.at_beginning_of_month" } ],
              [ I18n.t('time.this_year'), { :start => "Date.today.at_beginning_of_year", :end => "Date.today.at_end_of_year" } ],
              [ I18n.t('time.last_year'), { :start => "(Date.today.at_beginning_of_year - 10.days).at_beginning_of_year", :end => "(Date.today.at_beginning_of_year - 10.days).at_end_of_year" } ],
              [ I18n.t('time.yesterday_or_earlier'), { :start => "Time.utc(1000)", :end => "Date.yesterday" } ],
              [ I18n.t('time.yesterday_or_later'), { :start => "Date.yesterday", :end => "Time.utc(2100)" } ],
              [ I18n.t('time.tomorrow_or_earlier'), { :start => "Time.utc(1000)", :end => "Date.tomorrow" } ],
              [ I18n.t('time.tomorrow_or_later'), { :start => "Date.tomorrow", :end => "Time.utc(2100)" } ],
              [ I18n.t('time.today_or_later'), { :start => "Date.today", :end => "Time.utc(2100)" } ],
              [ I18n.t('time.today_or_earlier'), { :start => "Time.utc(1000)", :end => "Date.today" } ]
             ]

  FUTURE_KEYWORDS_LIST = [I18n.t('time.today_or_later'),I18n.t('time.tomorrow_or_later'),
                          I18n.t('time.yesterday_or_later'),I18n.t('time.in_the_future'),
                          I18n.t('time.yesterday_or_later'), I18n.t('time.tomorrow'),
                          I18n.t('time.tomorrow_or_earlier'), I18n.t('time.next_week')]

  # Updates or createself.create_defaultss the default time ranges
  def self.create_defaults
    DEFAULTS.each do |name, attrs|
      TimeRange.find_or_create_by_name(name).update_attributes(attrs)
    end
  end

  def TimeRange.end_time(name)
    eval(RANGES[name][1])
  end
  def TimeRange.start_time(name)
    eval(RANGES[name][0])
  end

  def self.keyword_in_future? (keyword)
    FUTURE_KEYWORDS_LIST.each do |name|
      if (name == keyword.to_s)
        return true
      end
    end
    return false
{'fraction_non_alphanumeric': 0.17792538157150933, 'fraction_numerical': 0.027416619559072923, 'mean_word_length': 2.875684556407448, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 75, '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': '7523228', 'n_tokens_mistral': 2825, 'n_tokens_neox': 2617, 'n_words': 398}