<commit_before>#encoding: utf-8
class CalendarsController < ApplicationController

  def show
    raise ActionController::RoutingError.new('Not Found') if current_region.nil?

    @categories     = Category.all
    @start_date     = determine_start_date
    @start_selector = StartSelector.new(@start_date, 8, 5)
    @calendar       = generate_calendar(@start_date, 4)
  end

  private

  def determine_start_date
    params[:start].present? ? Date.parse(params[:start]) : Date.today
  rescue ArgumentError
    Date.today
  end

  def generate_calendar(start_date, number_of_weeks)
    single_events = SingleEvent.in_next_from(number_of_weeks.weeks, start_date).in_region(@region)
    Calendar.new(single_events, current_user)
  end
end
<commit_msg>Calendars Controller: Simplify start_date<commit_after>#encoding: utf-8
class CalendarsController < ApplicationController

  def show
    raise ActionController::RoutingError.new('Not Found') if current_region.nil?

    @categories     = Category.all
    @start_selector = StartSelector.new(start_date, 8, 5)
    @calendar       = generate_calendar(start_date, 4)
  end

  private

  def start_date
    @start_date ||= begin
      Date.parse(params[:start])
    rescue ArgumentError, TypeError
      Date.today
    end
  end

  def generate_calendar(start_date, number_of_weeks)
    single_events = SingleEvent.in_next_from(number_of_weeks.weeks, start_date).in_region(@region)
    Calendar.new(single_events, current_user)
  end
end

{'fraction_non_alphanumeric': 0.08631153068105192, 'fraction_numerical': 0.005394470667565745, 'mean_word_length': 4.338129496402877, 'pattern_counts': {'":': 0, '<': 5, '<?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': '5272899', 'n_tokens_mistral': 475, 'n_tokens_neox': 450, 'n_words': 91}