Sha256: 4757cd740487ba47aa3942e6e8cf9dca521297efa92f5e7c88d72e7a3671ad42

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 KB

Contents

# frozen_string_literal: true

module Decidim
  module Meetings
    module Calendar
      # This class handles how to convert a component meetings to the ICalendar
      # format. It caches its result until the component is updated again.
      class ComponentCalendar < BaseCalendar
        # Renders the meetings in an ICalendar format. It caches the results in
        # Rails' cache.
        #
        # Returns a String.
        def events
          filtered_meetings.map do |meeting|
            MeetingCalendar.new(meeting).events
          end.compact.join
        end

        private

        alias component resource

        # Finds the component meetings.
        #
        # Returns a collection of Meetings.
        def meetings
          Decidim::Meetings::Meeting.where(component: component)
        end

        # Finds the component meetings.
        #
        # Returns a collection of Meetings filtered based on provided params.
        def filtered_meetings
          meetings.not_hidden.published.except_withdrawn.ransack(@filters).result
        end
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
decidim-meetings-0.27.9 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.27.8 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.27.7 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.27.6 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.27.5 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.27.4 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.27.3 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.27.2 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.27.1 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.27.0 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.27.0.rc2 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.27.0.rc1 app/services/decidim/meetings/calendar/component_calendar.rb