diff --git a/scripts/panoptes_membership_client.rb b/scripts/panoptes_membership_client.rb index 7e284d0..497eac4 100644 --- a/scripts/panoptes_membership_client.rb +++ b/scripts/panoptes_membership_client.rb @@ -44,8 +44,9 @@ def user_memberships(user_group_id, user_ids) def memberships_insert_query(memberships_to_create) # Values is part of sql query will look like ($1, $2, $3, $4), ($5, $6, $7, $8), ..etc.. - values = memberships_to_create.length.times.map { |i| "($#{(4 * i) + 1}, $#{(4 * i) + 2}, $#{(4 * i) + 3}, $#{(4 * i) + 4})" }.join(',') - + values = Array.new(memberships_to_create.length) do |i| + "($#{(4 * i) + 1}, $#{(4 * i) + 2}, $#{(4 * i) + 3}, $#{(4 * i) + 4})" + end.join(',') "INSERT INTO memberships (user_id, user_group_id, state, roles) VALUES #{values}" end end