Class: SpreeCmCommissioner::LoadTest::DestroyAccounts

Inherits:
Object
  • Object
show all
Includes:
Spree::ServiceModule::Base
Defined in:
app/services/spree_cm_commissioner/load_test/destroy_accounts.rb

Overview

Soft-deletes up to N load-test accounts for a scope (acts_as_paranoid). Since accounts now get random emails (see LoadTest::CreateAccounts), they can't be found by reconstructing a deterministic email — they're located by the load_test_account flag + tenant instead, the same way the admin UI lists them. Not needed on staging — accounts are reusable across runs.

Constant Summary collapse

SCAN_LIMIT =

Scan cap for the candidate set below — bounds the query while comfortably covering realistic load-test pool sizes (mirrors the admin controller's export scan).

2000

Instance Method Summary collapse

Instance Method Details

#call(client_id: nil, count: 20, **_ignored) ⇒ Object



14
15
16
17
18
19
20
21
22
23
# File 'app/services/spree_cm_commissioner/load_test/destroy_accounts.rb', line 14

def call(client_id: nil, count: 20, **_ignored)
  tenant = resolve_tenant(client_id)

  accounts = load_test_accounts(tenant).first(count)
  accounts.each(&:destroy!)

  success(destroyed: accounts.size, not_found: [count - accounts.size, 0].max)
rescue StandardError => e
  failure(nil, e.message)
end