From 928278d8b2d9e44ce367cf4c673161f8dd477be0 Mon Sep 17 00:00:00 2001 From: "Nadler, Sebastian" Date: Fri, 20 Sep 2024 12:17:55 +0200 Subject: [PATCH 1/3] Improved sync of recordings with BBB server --- lib/tasks/server_recordings_sync.rake | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/lib/tasks/server_recordings_sync.rake b/lib/tasks/server_recordings_sync.rake index e61903e47d..dc1df17da3 100644 --- a/lib/tasks/server_recordings_sync.rake +++ b/lib/tasks/server_recordings_sync.rake @@ -22,6 +22,10 @@ task :server_recordings_sync, %i[provider] => :environment do |_task, args| args.with_defaults(provider: 'greenlight') Room.includes(:user).select(:id, :meeting_id).with_provider(args[:provider]).in_batches(of: 25) do |rooms| + room_recordings = rooms.recordings + Format.where(recording: room_recordings).delete_all + room_recordings.delete_all + meeting_ids = rooms.pluck(:meeting_id) recordings = BigBlueButtonApi.new(provider: args[:provider]).get_recordings(meeting_ids:) @@ -30,14 +34,7 @@ task :server_recordings_sync, %i[provider] => :environment do |_task, args| next if recordings[:recordings].blank? - # Skip the entire batch if the first and last recordings exist - if Recording.exists?(record_id: recordings[:recordings][0][:recordID]) && Recording.exists?(record_id: recordings[:recordings][-1][:recordID]) - next - end - recordings[:recordings].each do |recording| - next if Recording.exists?(record_id: recording[:recordID]) - RecordingCreator.new(recording:).call success 'Successfully migrated Recording:' info "RecordID: #{recording[:recordID]}" From 24126ad19c4afa23f4b2856754bdea0f5d965cd1 Mon Sep 17 00:00:00 2001 From: "Nadler, Sebastian" Date: Mon, 23 Sep 2024 11:55:23 +0000 Subject: [PATCH 2/3] fix room sync --- lib/tasks/server_recordings_sync.rake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lib/tasks/server_recordings_sync.rake b/lib/tasks/server_recordings_sync.rake index dc1df17da3..60da6f75da 100644 --- a/lib/tasks/server_recordings_sync.rake +++ b/lib/tasks/server_recordings_sync.rake @@ -21,11 +21,13 @@ desc 'Server Recordings sync with BBB server' task :server_recordings_sync, %i[provider] => :environment do |_task, args| args.with_defaults(provider: 'greenlight') - Room.includes(:user).select(:id, :meeting_id).with_provider(args[:provider]).in_batches(of: 25) do |rooms| - room_recordings = rooms.recordings + Room.select do |room| + room_recordings = room.recordings Format.where(recording: room_recordings).delete_all room_recordings.delete_all + end + Room.includes(:user).select(:id, :meeting_id).with_provider(args[:provider]).in_batches(of: 25) do |rooms| meeting_ids = rooms.pluck(:meeting_id) recordings = BigBlueButtonApi.new(provider: args[:provider]).get_recordings(meeting_ids:) From e00aca332204a0bc950ff3c500cadde3801d582d Mon Sep 17 00:00:00 2001 From: "Nadler, Sebastian" Date: Tue, 8 Oct 2024 10:44:17 +0000 Subject: [PATCH 3/3] New comment --- spec/services/recordings_sync_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/services/recordings_sync_spec.rb b/spec/services/recordings_sync_spec.rb index 92a11caea8..4bf7c8035d 100644 --- a/spec/services/recordings_sync_spec.rb +++ b/spec/services/recordings_sync_spec.rb @@ -43,7 +43,7 @@ allow_any_instance_of(BigBlueButtonApi).to receive(:get_recordings).and_return(no_recording_response) end - it 'does not call RecordingsCreator service' do + it 'does not call RecordingsCreator service and delete all recordings' do expect_any_instance_of(BigBlueButtonApi).to receive(:get_recordings).with(meeting_ids: room.meeting_id) expect(RecordingCreator).not_to receive(:new)