Skip to content

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

Update limit computation to include ongoing meetings

Mir Bhatiab6198dca26e2
diff --git a/modules/meeting/app/controllers/recurring_meetings_controller.rb b/modules/meeting/app/controllers/recurring_meetings_controller.rb
index 792cb0a0503..658f627b077 100644
--- a/modules/meeting/app/controllers/recurring_meetings_controller.rb
+++ b/modules/meeting/app/controllers/recurring_meetings_controller.rb
@@ -287,7 +287,8 @@ class RecurringMeetingsController < ApplicationController
@recurring_meeting.scheduled_instances(upcoming: false).count
elsif @recurring_meeting.will_end?
open = @recurring_meeting.upcoming_instantiated_meetings
- @recurring_meeting.remaining_occurrences.count - open.count
+ ongoing = @recurring_meeting.ongoing_meetings
+ @recurring_meeting.remaining_occurrences.count - open.count + ongoing.count
end
@count = [show_more_limit_param, @max_count].compact.min
diff --git a/modules/meeting/app/models/recurring_meeting.rb b/modules/meeting/app/models/recurring_meeting.rb
index fc1df154344..bef5e839c9a 100644
--- a/modules/meeting/app/models/recurring_meeting.rb
+++ b/modules/meeting/app/models/recurring_meeting.rb
@@ -210,7 +210,7 @@ class RecurringMeeting < ApplicationRecord
end
def upcoming_instantiated_meetings
- scheduled_meetings
+ @upcoming_instantiated_meetings ||= scheduled_meetings
.includes(:meeting)
.not_cancelled
.joins(:meeting)
@@ -218,6 +218,13 @@ class RecurringMeeting < ApplicationRecord
.order(start_time: :asc)
end
+ def ongoing_meetings
+ upcoming_instantiated_meetings
+ .includes(:meeting)
+ .where(meetings: { start_time: ..Time.current })
+ .order(start_time: :asc)
+ end
+
def upcoming_cancelled_meetings
scheduled_meetings
.upcoming
diff --git a/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_show_spec.rb b/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_show_spec.rb
index e208515466c..3931c8374f4 100644
--- a/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_show_spec.rb
+++ b/modules/meeting/spec/requests/recurring_meetings/recurring_meetings_show_spec.rb
@@ -220,6 +220,40 @@ RSpec.describe "Recurring meetings show",
end
end
+ context "with an ongoing meeting" do
+ let(:recurring_meeting) do
+ create :recurring_meeting,
+ project:,
+ author: user,
+ start_time: Time.zone.today + 10.hours,
+ frequency: "daily",
+ end_after: "iterations",
+ iterations: 5
+ end
+ let!(:ongoing_instance) do
+ create :structured_meeting,
+ recurring_meeting:,
+ start_time: Time.zone.today + 10.hours - 10.minutes
+ end
+ let!(:ongoing) do
+ create :scheduled_meeting,
+ recurring_meeting:,
+ meeting: ongoing_instance,
+ start_time: Time.zone.today + 10.hours - 10.minutes
+ end
+
+ it "shows the correct number of next occurrences (Regression #61194)" do
+ # While today's meeting is ongoing, but no longer in remaining_occurrences
+ Timecop.freeze(Time.zone.today + 10.hours + 1.minute) do
+ get recurring_meeting_path(recurring_meeting)
+ end
+
+ (1..4).each do |date|
+ expect(page).to have_text format_time(Time.zone.today + date.days + 10.hours)
+ end
+ end
+ end
+
context "when user has no permissions to access" do
let(:current_user) { create(:user) }