refactor(ticket): simplify tenant validation and update command documentation
This commit is contained in:
@@ -122,10 +122,6 @@ class LoadTestTicketDatasetService
|
||||
int $scannerCount,
|
||||
int $ownerCount,
|
||||
): void {
|
||||
if (! str_starts_with($tenantCode, 'loadtest-')) {
|
||||
throw new InvalidArgumentException('El tenant debe comenzar con `loadtest-`.');
|
||||
}
|
||||
|
||||
foreach ([
|
||||
'tickets' => [$ticketCount, 100_000],
|
||||
'scanners' => [$scannerCount, 10_000],
|
||||
@@ -189,7 +185,7 @@ class LoadTestTicketDatasetService
|
||||
private function scanners(Tenant $tenant, CatalogItem $catalogItem, int $count): Collection
|
||||
{
|
||||
return Collection::times($count, function (int $number) use ($tenant, $catalogItem): User {
|
||||
$scanner = User::withTrashed()->updateOrCreate(
|
||||
$scanner = User::query()->updateOrCreate(
|
||||
['email' => $this->email($tenant, 'scanner', $number)],
|
||||
[
|
||||
'nombre_apellido' => "Load test scanner {$number}",
|
||||
@@ -198,8 +194,6 @@ class LoadTestTicketDatasetService
|
||||
'tenant_codigo' => $tenant->codigo,
|
||||
],
|
||||
);
|
||||
$scanner->restore();
|
||||
|
||||
if ($tenant->requiresScannerCategoryValidation()) {
|
||||
$scanner->scanCategories()->syncWithoutDetaching([$catalogItem->category_id]);
|
||||
}
|
||||
@@ -212,7 +206,7 @@ class LoadTestTicketDatasetService
|
||||
private function owners(Tenant $tenant, int $count): Collection
|
||||
{
|
||||
return Collection::times($count, function (int $number) use ($tenant): User {
|
||||
$owner = User::withTrashed()->updateOrCreate(
|
||||
$owner = User::query()->updateOrCreate(
|
||||
['email' => $this->email($tenant, 'owner', $number)],
|
||||
[
|
||||
'nombre_apellido' => "Load test owner {$number}",
|
||||
@@ -221,7 +215,6 @@ class LoadTestTicketDatasetService
|
||||
'tenant_codigo' => $tenant->codigo,
|
||||
],
|
||||
);
|
||||
$owner->restore();
|
||||
|
||||
return $owner;
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user