<commit_before>require Rails.root.join('db','seed_helper')

# NOTE:
#   the following provider names can be destroyed using the claims destroyer
#   and should therefore be used so that we can "clean-up" data on staging
#   and gamma (be very careful)
#
# SAMPLE_PROVIDERS = ['Test chamber','Test firm A', 'Test firm B']
#
#  #destroy the above providers and all their users and claims
#  rake claims.destroy_sample_providers
#

# Create an advocate and admin/clerk for AGFS Chamber
# -------------------------------------------------------
provider = SeedHelper.find_or_create_provider!(
  name: 'Test chamber',
  supplier_number: nil,
  api_key: ENV['TEST_CHAMBER_API_KEY'],
  provider_type: 'chamber',
  vat_registered: true,
  roles: ['agfs']
)

if User.find_by(email: '<EMAIL>').blank?
  user = User.create!(
    first_name: 'Barry',
    last_name: 'Stir',
    email: '<EMAIL>',
    password: ENV['<PASSWORD>'],
    password_confirmation: ENV['<PASSWORD>'],
  )

  external_user = ExternalUser.new(roles: ['advocate'], supplier_number: '11AAA', provider_id: provider.id)
  external_user.user = user
  external_user.save!
end

if User.find_by(email: '<EMAIL>').blank?
  user = User.create!(
    first_name: 'Advo',
    last_name: 'Kate-Admin',
    email: '<EMAIL>',
    password: ENV['<PASSWORD>'],
    password_confirmation: ENV['<PASSWORD>']
  )

  external_user = ExternalUser.new(roles: ['admin'], provider_id: provider.id)
  external_user.user = user
  external_user.save!
end

# Create a litigator and admin/clerk belonging to an LGFS Firm
# -------------------------------------------------------
provider = SeedHelper.find_or_create_provider!(
  name: 'Test firm A',
  supplier_number: '1A222Z',
  # api_key: ENV['TEST_CHAMBER_API_KEY'],
  provider_type: 'firm',
  vat_registered: true,
  roles: ['lgfs']
)

SeedHelper.create_supplier_numbers_for_provider(provider, %w(1A222Z 2A333Z 3A555Z))

if User.find_by(email: '<EMAIL>').blank?
  user = User.create!(
    first_name: 'Liti',
    last_name: 'Gator',
    email: '<EMAIL>',
    password: ENV['<PASSWORD>'],
    password_confirmation: ENV['ADVOC<PASSWORD>']<commit_msg>Change wrong supplier number in demo data seed.<commit_after>require Rails.root.join('db','seed_helper')

# NOTE:
#   the following provider names can be destroyed using the claims destroyer
#   and should therefore be used so that we can "clean-up" data on staging
#   and gamma (be very careful)
#
# SAMPLE_PROVIDERS = ['Test chamber','Test firm A', 'Test firm B']
#
#  #destroy the above providers and all their users and claims
#  rake claims.destroy_sample_providers
#

# Create an advocate and admin/clerk for AGFS Chamber
# -------------------------------------------------------
provider = SeedHelper.find_or_create_provider!(
  name: 'Test chamber',
  supplier_number: nil,
  api_key: ENV['TEST_CHAMBER_API_KEY'],
  provider_type: 'chamber',
  vat_registered: true,
  roles: ['agfs']
)

if User.find_by(email: '<EMAIL>').blank?
  user = User.create!(
    first_name: 'Barry',
    last_name: 'Stir',
    email: '<EMAIL>',
    password: ENV['<PASSWORD>'],
    password_confirmation: ENV['AD<PASSWORD>'],
  )

  external_user = ExternalUser.new(roles: ['advocate'], supplier_number: '11AAA', provider_id: provider.id)
  external_user.user = user
  external_user.save!
end

if User.find_by(email: '<EMAIL>').blank?
  user = User.create!(
    first_name: 'Advo',
    last_name: 'Kate-Admin',
    email: '<EMAIL>',
    password: ENV['<PASSWORD>'],
    password_confirmation: ENV['ADMIN_PASSWORD']
  )

  external_user = ExternalUser.new(roles: ['admin'], provider_id: provider.id)
  external_user.user = user
  external_user.save!
end

# Create a litigator and admin/clerk belonging to an LGFS Firm
# -------------------------------------------------------
provider = SeedHelper.find_or_create_provider!(
  name: 'Test firm A',
  supplier_number: '1A222',
  # api_key: ENV['TEST_CHAMBER_API_KEY'],
  provider_type: 'firm',
  vat_registered: true,
  roles: ['lgfs']
)

SeedHelper.create_supplier_numbers_for_provider(provider, %w(1A222Z 2A333Z 3A555Z))

if User.find_by(email: '<EMAIL>').blank?
  user = User.create!(
    first_name: 'Liti',
    last_name: 'Gator',
    email: '<EMAIL>',
    password: ENV['<PASSWORD>'],
    password_confirmation: ENV['<PASSWORD>']
{'fraction_non_alphanumeric': 0.18209302325581395, 'fraction_numerical': 0.008372093023255815, 'mean_word_length': 3.629709364908504, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6427808', 'n_tokens_mistral': 1486, 'n_tokens_neox': 1439, 'n_words': 346}