<commit_before># encoding: utf-8
require 'date'
require 'time'
require 'event'
require 'event/year'

# Present calendar views of events.
class CalendarController < ApplicationController
  before_filter :set_user
  before_filter :require_year
  before_filter :require_month, except: [:year]
  before_filter :require_day, only: [:day]
  before_filter :set_section

  def year
    year = @date.year
    page_metadata(title: year.to_s, description: "Calendar of events for #{year}.")
    @total_event_count = Event.approved.falls_between_dates(Date.new(year, 1, 1), Date.new(year, 12, 31)).count
    @event_counts = Wayground::Event::Year.new(year: year).monthly_event_counts
    render( {locals: {foo: 'bar'}} )
  end

  def month
    title_date = @date.strftime('%B %Y')
    page_metadata(title: title_date, description: "Calendar of events for #{title_date}.")
    month_start = Date.new(@date.year, @date.month, 1)
    month_end = (month_start + 1.month) - 1.day
    @events = Event.approved.falls_between_dates(month_start, month_end)
  end

  def day
    title_date = @date.strftime('%B %-e, %Y')
    page_metadata(title: title_date, description: "Calendar of events for #{title_date}.")
    @events = Event.approved.falls_on_date(Date.new(@date.year, @date.month, @date.day))
  end

  protected

  def set_user
    @user = current_user<commit_msg>[CalendarController] include site name in meta description for actions.<commit_after># encoding: utf-8
require 'date'
require 'time'
require 'event'
require 'event/year'

# Present calendar views of events.
class CalendarController < ApplicationController
  before_filter :set_user
  before_filter :require_year
  before_filter :require_month, except: [:year]
  before_filter :require_day, only: [:day]
  before_filter :set_section

  def year
    year = @date.year
    page_metadata(title: year.to_s, description: "#{Wayground::Application::NAME} calendar of events for #{year}.")
    @total_event_count = Event.approved.falls_between_dates(Date.new(year, 1, 1), Date.new(year, 12, 31)).count
    @event_counts = Wayground::Event::Year.new(year: year).monthly_event_counts
    render( {locals: {foo: 'bar'}} )
  end

  def month
    title_date = @date.strftime('%B %Y')
    page_metadata(title: title_date, description: "#{Wayground::Application::NAME} calendar of events for #{title_date}.")
    month_start = Date.new(@date.year, @date.month, 1)
    month_end = (month_start + 1.month) - 1.day
    @events = Event.approved.falls_between_dates(month_start, month_end)
  end

  def day
    title_date = @date.strftime('%B %-e, %Y')
    page_metadata(title: title_date, description: "#{Wayground::Application::NAME} calendar of events for #{title_date}.")
    @events = Event.approved.falls_on_date(Date.new(@date.year, @date.month, @date.day))
  end

  protected

  def set_user
    @user = current_user
{'fraction_non_alphanumeric': 0.1296426068675543, 'fraction_numerical': 0.00700770847932726, 'mean_word_length': 4.721442885771543, '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': '4137039', 'n_tokens_mistral': 979, 'n_tokens_neox': 934, 'n_words': 228}