Sha256: 7bd2bfc2657ab68746bd7eb57694e88084e1e87e07b218ded726a8ec5c42e6db

Contents?: true

Size: 1.06 KB

Versions: 6

Compression:

Stored size: 1.06 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:)
        end

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

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-meetings-0.29.1 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.29.0 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.29.0.rc4 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.29.0.rc3 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.29.0.rc2 app/services/decidim/meetings/calendar/component_calendar.rb
decidim-meetings-0.29.0.rc1 app/services/decidim/meetings/calendar/component_calendar.rb