OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
use new wrapper in AllMeetings service
Klaus Zanders9dc91489bcc2
diff --git a/modules/meeting/app/services/all_meetings/ical_service.rb b/modules/meeting/app/services/all_meetings/ical_service.rbindex dc9796af195..a9e980d427d 100644--- a/modules/meeting/app/services/all_meetings/ical_service.rb+++ b/modules/meeting/app/services/all_meetings/ical_service.rb@@ -31,31 +31,36 @@ require "icalendar"require "icalendar/tzinfo"module AllMeetingsclass ICalService- include Meetings::ICalHelpers- attr_reader :user, :url_helpers, :include_historic, :calendar, :timezone+ attr_reader :user, :include_historicdef initialize(user:, include_historic: false)@user = user- @timezone = user.time_zone- @url_helpers = OpenProject::StaticRouting::StaticUrlHelpers.new@include_historic = include_historic- @calendar = build_icalendar(Time.current.in_time_zone(user.time_zone))end- def call- single_meetings.each do |meeting|- build_single_meeting(meeting)- end+ def call # rubocop:disable Metrics/AbcSize+ User.execute_as(user) do+ calendar = Meetings::CalendarWrapper.new(timezone: Time.zone || Time.zone_default)- ServiceResult.success(result: calendar.to_ical)- end+ single_meetings.each do |meeting|+ calendar.add_single_meeting_event(meeting:, cancelled: false)+ end- private+ # This generates a lot of subqueries.+ # TODO: Optimize this to avoid subqueries.+ recurring_meetings.each do |recurring_meeting|+ calendar.add_series_event(recurring_meeting:, cancelled: false)+ end- def ical_subject(meeting)- "[#{meeting.project.name}] #{I18n.t(:label_meeting)}: #{meeting.title}"+ ServiceResult.success(result: calendar.to_ical)+ end+ rescue StandardError => e+ Rails.logger.error("Failed to generate ICS for meeting #{@meeting.id}: #{e.message}")+ ServiceResult.failure(message: e.message)end+ private+def recurring_meetings@recurring_meetings ||= RecurringMeeting.visible(user)end