<commit_before># Controller for schedule/calendar in different formats. Default to current year if not provided.
#
# Caches all of its pages
class ScheduleController < ApplicationController
  caches_page :index, :list
  
  # Default calendar format
  # mbrahere default format is list
  # === Params
  # * year: default to current year
  # * discipline
  # === Assigns
  # * year
  # * schedule: instance of year's Schedule::Schedule
  def index
    collect_schedule_data
    render_page
  end

  # List of events -- one line per event
  # === Params
  # * year: default to current year
  # === Assigns
  # * year
  # * schedule: instance of year's Schedule::Schedule
  def list
    collect_schedule_data
    render_page
  end

  def calendar
    collect_schedule_data
    render_page
  end

  private

#  mbrahere added the following method for the sake of dryness
  def collect_schedule_data
      @year = params["year"].to_i
      @year = Date.today.year if @year == 0
      @discipline = Discipline[params["discipline"]]
      @discipline_names = Discipline.find_all_names  #mbrahere added this line
      events = SingleDayEvent.find_all_by_year(@year, @discipline)
      @schedule = Schedule::Schedule.new(@year, events)
  end

end<commit_msg>Push DRY'ed up data assignments in filters<commit_after># Controller for schedule/calendar in different formats. Default to current year if not provided.
#
# Caches all of its pages
class ScheduleController < ApplicationController
  caches_page :index, :list, :calendar
  
  before_filter :assign_schedule_data
  
  # Default calendar format
  # === Params
  # * year: default to current year
  # * discipline
  # === Assigns
  # * year
  # * schedule: instance of year's Schedule::Schedule
  def index
    render_page
  end

  # List of events -- one line per event
  # === Params
  # * year: default to current year
  # === Assigns
  # * year
  # * schedule: instance of year's Schedule::Schedule
  def list
    render_page
  end

  def calendar
    render_page
  end

  private

  def assign_schedule_data
    @year = params["year"].to_i
    @year = Date.today.year if @year == 0
    @discipline = Discipline[params["discipline"]]
    @discipline_names = Discipline.find_all_names
    events = SingleDayEvent.find_all_by_year(@year, @discipline)
    @schedule = Schedule::Schedule.new(@year, events)
  end
end

{'fraction_non_alphanumeric': 0.0859441151566469, 'fraction_numerical': 0.000846740050804403, 'mean_word_length': 3.4669187145557654, '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': '6704135', 'n_tokens_mistral': 725, 'n_tokens_neox': 697, 'n_words': 222}