Skip to content

Commit

Permalink
add script for seeding license users
Browse files Browse the repository at this point in the history
  • Loading branch information
ezekg committed Dec 12, 2023
1 parent e04cdc6 commit b4ca925
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 44 deletions.

This file was deleted.

This file was deleted.

22 changes: 22 additions & 0 deletions db/scripts/seed_license_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# frozen_string_literal: true

# heroku run:detached -e SLEEP_DURATION=0.5 --tail \
# rails runner db/scripts/seed_license_users.rb

SLEEP_DURATION = ENV.fetch('SLEEP_DURATION') { 1 }.to_f

licenses = License.where_assoc_not_exists(:license_users)
.where_assoc_exists(:user)
.includes(:user)

Rails.logger.info "Seeding #{licenses.count} license_users"

licenses.find_each do |license|
Rails.logger.info "Seeding license_user for license=#{license.id} <> user=#{license.user_id}"

license.users << license.user

sleep SLEEP_DURATION
end

Rails.logger.info "Done"
11 changes: 0 additions & 11 deletions db/scripts/seed_machine_matching_strategy_for_policies_script.rb

This file was deleted.

11 changes: 0 additions & 11 deletions db/scripts/seed_machine_uniqueness_strategy_for_policies_script.rb

This file was deleted.

0 comments on commit b4ca925

Please sign in to comment.