<commit_before>require 'open-uri'

class Reservation < ActiveRecord::Base
  attr_accessible :cleaning_scheduled, :end_date, :name, :start_date, :status, :uid, :welcome_sent, :cleaning_completed
  
  validates_presence_of :uid
  validates_uniqueness_of :uid

  default_scope order("start_date ASC")
  scope :future, where("end_date > ?", Time.now)
  scope :needs_housekeeping_scheduled, where(cleaning_scheduled: false)
  
  def current?
    start_date.past? && end_date.future?
  end
  
  def soon?
    start_date.future? && start_date - Time.now < 5.days
  end
  
  def self.import_from_ics(ics_file_uri = Preference.get(:ics_url))<commit_msg>Use env var to pull ICS url<commit_after>require 'open-uri'

class Reservation < ActiveRecord::Base
  attr_accessible :cleaning_scheduled, :end_date, :name, :start_date, :status, :uid, :welcome_sent, :cleaning_completed
  
  validates_presence_of :uid
  validates_uniqueness_of :uid

  default_scope order("start_date ASC")
  scope :future, where("end_date > ?", Time.now)
  scope :needs_housekeeping_scheduled, where(cleaning_scheduled: false)
  
  def current?
    start_date.past? && end_date.future?
  end
  
  def soon?
    start_date.future? && start_date - Time.now < 5.days
  end
  
  def self.import_from_ics(ics_file_uri = ENV['ICS_URL'] || Preference.get(:ics_url))
{'fraction_non_alphanumeric': 0.10909090909090909, 'fraction_numerical': 0.0015151515151515152, 'mean_word_length': 5.031963470319635, 'pattern_counts': {'":': 0, '<': 7, '<?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': '4790717', 'n_tokens_mistral': 482, 'n_tokens_neox': 467, 'n_words': 94}