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
Remove meeting time slots calculation
Oliver Güntherc6738664b4b1
diff --git a/app/services/journals/create_service/agenda_itemable.rb b/app/services/journals/create_service/agenda_itemable.rbindex 7f0f2196136..e976c50c1e8 100644--- a/app/services/journals/create_service/agenda_itemable.rb+++ b/app/services/journals/create_service/agenda_itemable.rb@@ -52,8 +52,6 @@ class Journals::CreateServicenotes,position,duration_in_minutes,- start_time,- end_time,work_package_id,item_type)@@ -65,8 +63,6 @@ class Journals::CreateServiceagenda_items.notes,agenda_items.position,agenda_items.duration_in_minutes,- agenda_items.start_time,- agenda_items.end_time,agenda_items.work_package_id,agenda_items.item_typeFROM meeting_agenda_items agenda_items@@ -99,8 +95,6 @@ class Journals::CreateService#{normalize_newlines_sql('meeting_agenda_item_journals.notes')})OR (agenda_items.position IS DISTINCT FROM meeting_agenda_item_journals.position)OR (agenda_items.duration_in_minutes IS DISTINCT FROM meeting_agenda_item_journals.duration_in_minutes)- OR (agenda_items.start_time IS DISTINCT FROM meeting_agenda_item_journals.start_time)- OR (agenda_items.end_time IS DISTINCT FROM meeting_agenda_item_journals.end_time)OR (agenda_items.work_package_id IS DISTINCT FROM meeting_agenda_item_journals.work_package_id)OR (agenda_items.item_type IS DISTINCT FROM meeting_agenda_item_journals.item_type)SQLdiff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erbindex b6f30ae04e7..39641ca2a20 100644--- a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.html.erb@@ -40,7 +40,7 @@endif @meeting_agenda_item.duration_in_minutes.present? && @meeting_agenda_item.duration_in_minutes > 0- grid.with_area(:duration, Primer::Beta::Text, color: duration_color_scheme, mr: 2) do+ grid.with_area(:duration, Primer::Beta::Text, color: :subtle, mr: 2) doI18n.t("datetime.distance_in_words.x_minutes_abbreviated", count: @meeting_agenda_item.duration_in_minutes)endenddiff --git a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rbindex 81536db65fe..8755b35e633 100644--- a/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb+++ b/modules/meeting/app/components/meeting_agenda_items/item_component/show_component.rb@@ -231,14 +231,6 @@ module MeetingAgendaItemsendend- def duration_color_scheme- if @meeting.end_time < @meeting_agenda_item.end_time- :danger- else- :subtle- end- end-def notes_classesif @meeting.open?"op-uc-container override"diff --git a/modules/meeting/app/models/meeting.rb b/modules/meeting/app/models/meeting.rbindex 26c579a5793..8bdc08b324e 100644--- a/modules/meeting/app/models/meeting.rb+++ b/modules/meeting/app/models/meeting.rb@@ -246,25 +246,6 @@ class Meeting < ApplicationRecord.where(user_id: available_members)end- # triggered by MeetingAgendaItem#after_create/after_destroy/after_save- def calculate_agenda_item_time_slots- current_time = start_time- MeetingAgendaItem.transaction do- changed_items = agenda_items.includes(:meeting_section).order("meeting_sections.position", :position).map do |top|- start_time = current_time- current_time += top.duration_in_minutes&.minutes || 0.minutes- end_time = current_time- top.assign_attributes(start_time:, end_time:)- top- end-- MeetingAgendaItem.upsert_all(- changed_items.map(&:attributes),- unique_by: :id- )- end- end-def agenda_items_sum_duration_in_minutesagenda_items.sum(:duration_in_minutes)enddiff --git a/modules/meeting/app/models/meeting_agenda_item.rb b/modules/meeting/app/models/meeting_agenda_item.rbindex 0c8e602fff6..b1c17e383ab 100644--- a/modules/meeting/app/models/meeting_agenda_item.rb+++ b/modules/meeting/app/models/meeting_agenda_item.rb@@ -67,12 +67,8 @@ class MeetingAgendaItem < ApplicationRecordallow_nil: truebefore_validation :add_to_latest_meeting_section- after_save :trigger_meeting_agenda_item_time_slots_calculation, if: Proc.new { |item|- item.duration_in_minutes_previously_changed? || item.position_previously_changed?- }before_save :update_meeting_to_match_sectionafter_update :delete_default_section_if_last_item_moved, if: :saved_change_to_meeting_section_id?- after_destroy :trigger_meeting_agenda_item_time_slots_calculationafter_destroy :delete_default_section_if_last_item_deleteddef add_to_latest_meeting_section@@ -115,10 +111,6 @@ class MeetingAgendaItem < ApplicationRecordself.meeting = meeting_section.meetingend- def trigger_meeting_agenda_item_time_slots_calculation- meeting.calculate_agenda_item_time_slots- end-def linked_work_package?item_type == "work_package" && work_package.present?enddiff --git a/modules/meeting/app/models/meeting_section.rb b/modules/meeting/app/models/meeting_section.rbindex ac12368913e..d0e1aea321d 100644--- a/modules/meeting/app/models/meeting_section.rb+++ b/modules/meeting/app/models/meeting_section.rb@@ -36,20 +36,12 @@ class MeetingSection < ApplicationRecordhas_many :agenda_items, dependent: :destroy, class_name: "MeetingAgendaItem"has_one :project, through: :meeting- after_save :trigger_meeting_agenda_item_time_slots_calculation, if: Proc.new { |section|- section.position_previously_changed?- }-acts_as_list scope: [:meeting_id, { backlog: false }]default_scope { order(:position) }scope :backlog, -> { where(backlog: true) }- def trigger_meeting_agenda_item_time_slots_calculation- meeting.calculate_agenda_item_time_slots- end-def untitled?title.blank?enddiff --git a/modules/meeting/db/migrate/20250804083253_remove_times_for_meeting_agenda_items.rb b/modules/meeting/db/migrate/20250804083253_remove_times_for_meeting_agenda_items.rbnew file mode 100644index 00000000000..1bd865cda94--- /dev/null+++ b/modules/meeting/db/migrate/20250804083253_remove_times_for_meeting_agenda_items.rb@@ -0,0 +1,11 @@+# frozen_string_literal: true++class RemoveTimesForMeetingAgendaItems < ActiveRecord::Migration[8.0]+ def change+ remove_column :meeting_agenda_items, :start_time, :timestamp+ remove_column :meeting_agenda_items, :end_time, :timestamp++ remove_column :meeting_agenda_item_journals, :start_time, :timestamp+ remove_column :meeting_agenda_item_journals, :end_time, :timestamp+ end+enddiff --git a/modules/meeting/spec/models/meeting_agenda_item_spec.rb b/modules/meeting/spec/models/meeting_agenda_item_spec.rbindex 9847ab4b879..5c1d86a233d 100644--- a/modules/meeting/spec/models/meeting_agenda_item_spec.rb+++ b/modules/meeting/spec/models/meeting_agenda_item_spec.rb@@ -326,133 +326,4 @@ RSpec.describe MeetingAgendaItem doendendend-- describe "automatic updates to the start and end time", :aggregate_failures do- let(:user) { create(:user) }- let(:meeting) { create(:meeting, start_time: Time.current) }- let(:section) { create(:meeting_section, meeting:) }- let(:first_agenda_item) do- described_class.create(- title: "First item",- meeting:,- author: user,- duration_in_minutes: 15- )- end- let(:second_agenda_item) do- described_class.create(- title: "First item",- meeting:,- author: user,- duration_in_minutes: 10- )- end- let(:meeting_time) do- meeting.reload- meeting.start_time- end-- context "when creating agenda items" do- before do- first_agenda_item.reload- second_agenda_item.reload- end-- it "updates time slots" do- expect(first_agenda_item.start_time).to eq(meeting_time)- expect(first_agenda_item.end_time).to eq(meeting_time + first_agenda_item.duration_in_minutes.minutes)- expect(second_agenda_item.start_time).to eq(meeting_time + first_agenda_item.duration_in_minutes.minutes)- expect(second_agenda_item.end_time).to eq(meeting_time +- first_agenda_item.duration_in_minutes.minutes +- second_agenda_item.duration_in_minutes.minutes)- end- end-- context "when updating agenda items" do- before do- first_agenda_item.reload- second_agenda_item.reload- end-- context "when changing duration" do- it "updates time slots" do- expect do- first_agenda_item.update(duration_in_minutes: 30)- first_agenda_item.reload- second_agenda_item.reload- end- .to not_change { first_agenda_item.start_time }- .and change(first_agenda_item, :end_time)- .from(meeting_time + 15.minutes)- .to(meeting_time + 30.minutes)- .and change(second_agenda_item, :start_time)- .from(meeting_time + 15.minutes)- .to(meeting_time + 30.minutes)- .and change(second_agenda_item, :end_time)- .from(meeting_time + 15.minutes + second_agenda_item.duration_in_minutes.minutes)- .to(meeting_time + 30.minutes + second_agenda_item.duration_in_minutes.minutes)- end- end-- context "when changing position" do- it "updates time slots for all items" do- expect do- second_agenda_item.update(position: 1)-- first_agenda_item.reload- second_agenda_item.reload- end- .to change(first_agenda_item, :start_time)- .from(meeting_time)- .to(meeting_time + second_agenda_item.duration_in_minutes.minutes)- .and change(first_agenda_item, :end_time)- .from(meeting_time + first_agenda_item.duration_in_minutes.minutes)- .to(meeting_time +- second_agenda_item.duration_in_minutes.minutes +- first_agenda_item.duration_in_minutes.minutes)- .and change(second_agenda_item, :start_time)- .from(meeting_time + first_agenda_item.duration_in_minutes.minutes)- .to(meeting_time)- .and change(second_agenda_item, :end_time)- .from(meeting_time +- second_agenda_item.duration_in_minutes.minutes +- first_agenda_item.duration_in_minutes.minutes)- .to(meeting_time + second_agenda_item.duration_in_minutes.minutes)- end- end-- context "when changing other attributes" do- it "does not update time slots" do- expect do- first_agenda_item.update(title: "New title")- first_agenda_item.reload- end- .to not_change { first_agenda_item.start_time }- .and(not_change { first_agenda_item.end_time })- end- end- end-- context "when destroying an agenda item" do- before do- first_agenda_item.reload- second_agenda_item.reload- end-- it "updates time slots for remaining items" do- expect do- first_agenda_item.destroy- second_agenda_item.reload- end- .to change(second_agenda_item, :start_time)- .from(meeting_time + first_agenda_item.duration_in_minutes.minutes)- .to(meeting_time)- .and change(second_agenda_item, :end_time)- .from(meeting_time +- first_agenda_item.duration_in_minutes.minutes +- second_agenda_item.duration_in_minutes.minutes)- .to(meeting_time + second_agenda_item.duration_in_minutes.minutes)- end- end- endend