Sha256: d8e3c5a96cb0e94f3710e97063ffa3464116e5abcfa114bc29af2d475d023ef7

Contents?: true

Size: 670 Bytes

Versions: 1

Compression:

Stored size: 670 Bytes

Contents

# frozen_string_literal: true

module Admin
  module CalendarsHelper
    def calendar_pages(locale)
      Page.where(
        id: Page.with_dates.visible.pluck(:parent_page_id).uniq.compact
      ).in_locale(locale)
    end

    def calendar_years_with_count
      calendar_counts.each_with_object({}) do |entry, obj|
        obj[entry[:year]] ||= 0
        obj[entry[:year]] += entry[:count]
      end
    end

    def calendar_months_count(year)
      calendar_counts.filter { |e| e[:year] == year }
                     .map { |e| [e[:month], e[:count]] }
    end

    private

    def calendar_counts
      @calendar_counts ||= Page.count_by_month
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
pages_core-3.12.0 app/helpers/admin/calendars_helper.rb