Sha256: 5a56f731af5aae80914ce7bcc8f7d30c3f0966c4248a0d894616c601ab8b599d

Contents?: true

Size: 914 Bytes

Versions: 1

Compression:

Stored size: 914 Bytes

Contents

module Calagator
  class Event < ActiveRecord::Base
    class Overview
      def today
        Event.non_duplicates.within_dates(today_date, tomorrow_date)
      end

      def tomorrow
        Event.non_duplicates.within_dates(tomorrow_date, after_tomorrow_date)
      end

      def later
        Event.non_duplicates.within_dates(after_tomorrow_date, future_cutoff_date)
      end

      def more
        Event.after_date(future_cutoff_date).first
      end

      def tags
        @tags ||= Event.tag_counts_on(:tags, limit: 100, conditions: 'tags_count >= 10').sort_by(&:name)
      end

      private

      def today_date
        @today_date ||= Time.zone.now.beginning_of_day
      end

      def tomorrow_date
        today_date + 1.day
      end

      def after_tomorrow_date
        tomorrow_date + 1.day
      end

      def future_cutoff_date
        today_date + 2.weeks
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
calagator-1.1.0 app/models/calagator/event/overview.rb