Skip to content
Snippets Groups Projects
Unverified Commit 8d78d898 authored by Samuel Couillard's avatar Samuel Couillard Committed by GitHub
Browse files

Resources migration: Added `migrations:rooms` task (#4013)

* Initial commit

* Fix path

* Add owner_email and owner_provider attributes

* Add to_datetime to last_session

* Add range to rooms migration

* quickfix

* Change user to owner and add id to Room select

* Revert last commit
parent e2fc50af
No related branches found
No related tags found
No related merge requests found
...@@ -74,6 +74,43 @@ namespace :migrations do ...@@ -74,6 +74,43 @@ namespace :migrations do
exit has_encountred_issue exit has_encountred_issue
end end
task :rooms, [:start, :stop] => :environment do |_task, args|
start, stop = range(args)
has_encountred_issue = 0
Room.select(:id, :uid, :name, :bbb_id, :last_session, :user_id)
.find_each(start: start, finish: stop, batch_size: COMMON[:batch_size]).each do |r|
params = { room: { friendly_id: r.uid,
name: r.name,
meeting_id: r.bbb_id,
last_session: r.last_session&.to_datetime,
owner_email: r.owner.email } }
response = Net::HTTP.post(uri('rooms'), payload(params), COMMON[:headers])
case response
when Net::HTTPCreated
puts green "Succesfully migrated Room:"
puts cyan " UID: #{r.uid}"
puts cyan " Name: #{r.name}"
else
puts red "Unable to migrate Room:"
puts yellow " UID: #{r.uid}"
puts yellow " Name: #{r.name}"
has_encountred_issue = 1 # At least one of the migrations failed.
end
end
puts
puts green "Rooms migration completed."
unless has_encountred_issue.zero?
puts yellow "In case of an error please retry the process to resolve."
puts yellow "If you have not migrated your users, kindly run 'rake migrations:users' first and then retry."
end
exit has_encountred_issue
end
private private
def encrypt_params(params) def encrypt_params(params)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment