<commit_before>class PrisonSchedule < Struct.new(:prison)

  delegate :days_lead_time, :booking_window, to: :prison

  def confirmation_email_date
    staff_working_days.take(prison_processing_days).last
  end

  def available_visitation_dates
    available_visitation_range.reduce([]) do |valid_dates, day|
      valid_dates.tap do |dates|
        dates << day if PrisonDay.new(day, prison).visiting_day?
      end
    end
  end

  private

  def staff_working_days
    Enumerator.new do |y|
      confirmation_email_range.each do |day|
        y << day if PrisonDay.new(day, prison).staff_working_day?
      end
    end
  end

  def confirmation_email_range
    # Use an arbitary number of days to apply the filter on
    Date.today..last_bookable_day
  end

  def available_visitation_range
    confirmation_email_date.next_day..last_bookable_day
  end

  def last_bookable_day
    booking_window.days.from_now.to_date
  end

  def prison_processing_days
    # increment the value as `#take` on a range is not zero based<commit_msg>Use Time.zone instead of Date.today<commit_after>class PrisonSchedule < Struct.new(:prison)

  delegate :days_lead_time, :booking_window, to: :prison

  def confirmation_email_date
    staff_working_days.take(prison_processing_days).last
  end

  def available_visitation_dates
    available_visitation_range.reduce([]) do |valid_dates, day|
      valid_dates.tap do |dates|
        dates << day if PrisonDay.new(day, prison).visiting_day?
      end
    end
  end

  private

  def staff_working_days
    Enumerator.new do |y|
      confirmation_email_range.each do |day|
        y << day if PrisonDay.new(day, prison).staff_working_day?
      end
    end
  end

  def confirmation_email_range
    # Use an arbitary number of days to apply the filter on
    Time.zone.today..last_bookable_day
  end

  def available_visitation_range
    confirmation_email_date.next_day..last_bookable_day
  end

  def last_bookable_day
    booking_window.days.from_now.to_date
  end

  def prison_processing_days
    # increment the value as `#take` on a range is not zero based
{'fraction_non_alphanumeric': 0.06342393896041965, 'fraction_numerical': 0.0, 'mean_word_length': 3.5608695652173914, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 3, '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': '6922475', 'n_tokens_mistral': 686, 'n_tokens_neox': 658, 'n_words': 169}