Pint: Formatierung des bisherigen Stands, ohne inhaltliche Aenderung

Die Dateien lagen im Arbeitsbaum formatiert und inhaltlich geaendert
zusammen. Dieser Commit enthaelt nur die Pint-Formatierung des alten
Stands, damit die folgenden Commits nur noch Inhalt zeigen.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
Kevin 2026-09-23 15:39:17 +00:00
parent bdef77462d
commit 316a9b76d6
33 changed files with 880 additions and 841 deletions

View file

@ -2,17 +2,18 @@
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\User;
use App\Services\ShoppingUserService;
use App\User;
use Exception;
use Illuminate\Support\Facades\Log;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;
class SyncShoppingUserData extends Command
{
//aufruf: php artisan shopping:sync-user-data --force --start=4
// aufruf: php artisan shopping:sync-user-data --force --start=4
protected $signature = 'shopping:sync-user-data {user_id?} {--force} {--start=1}';
protected $description = 'Synchronisiere Shopping User Daten für einen oder alle User';
public function handle()
@ -28,11 +29,12 @@ class SyncShoppingUserData extends Command
$this->syncAllUsers($force, $startId);
}
} catch (Exception $e) {
$this->error("Ein Fehler ist aufgetreten: " . $e->getMessage());
Log::error("Shopping User Sync Fehler: ", [
$this->error('Ein Fehler ist aufgetreten: '.$e->getMessage());
Log::error('Shopping User Sync Fehler: ', [
'error' => $e->getMessage(),
'trace' => $e->getTraceAsString()
'trace' => $e->getTraceAsString(),
]);
return 1;
}
@ -50,27 +52,27 @@ class SyncShoppingUserData extends Command
User::where('id', '>=', $startId)
->orderBy('id')
->chunk(10, function($users) use (&$count, &$errors, $force) {
foreach($users as $user) {
->chunk(10, function ($users) use (&$count, &$errors, $force) {
foreach ($users as $user) {
try {
$this->info("\nVerarbeite User ID: {$user->id} ({$user->email})");
$this->syncUser($user);
$count++;
$this->info("✓ User ID {$user->id} erfolgreich synchronisiert");
} catch (Exception $e) {
$errorMessage = "Fehler bei User ID {$user->id} ({$user->email}): " . $e->getMessage();
$errorMessage = "Fehler bei User ID {$user->id} ({$user->email}): ".$e->getMessage();
$errors[] = $errorMessage;
$this->error($errorMessage);
// Log die letzten SQL Queries
Log::error("Letzte SQL Queries:", [
'queries' => DB::getQueryLog()
Log::error('Letzte SQL Queries:', [
'queries' => DB::getQueryLog(),
]);
if (!$force) {
if (! $force) {
throw $e;
}
}
@ -78,13 +80,13 @@ class SyncShoppingUserData extends Command
});
$this->newLine();
$this->info("Synchronisierung abgeschlossen!");
$this->info('Synchronisierung abgeschlossen!');
$this->info("Gesamt synchronisierte User: {$count}");
if (count($errors) > 0) {
$this->warn("Es gab " . count($errors) . " Fehler während der Synchronisierung:");
foreach($errors as $error) {
$this->warn("- " . $error);
$this->warn('Es gab '.count($errors).' Fehler während der Synchronisierung:');
foreach ($errors as $error) {
$this->warn('- '.$error);
}
}
}
@ -92,38 +94,37 @@ class SyncShoppingUserData extends Command
private function syncUser(User $user)
{
try {
$this->output->write(" Setze Faker Mail... ");
$this->output->write(' Setze Faker Mail... ');
ShoppingUserService::setFakerMail($user);
$this->info("✓");
$this->info('✓');
$this->output->write(" Synchronisiere Numbers... ");
$this->output->write(' Synchronisiere Numbers... ');
ShoppingUserService::syncNumbersByEmail($user);
$this->info("✓");
$this->info('✓');
$this->output->write(" Synchronisiere Orders... ");
$this->output->write(' Synchronisiere Orders... ');
ShoppingUserService::syncOrdersByEmail($user);
$this->info("✓");
$this->info('✓');
} catch (Exception $e) {
throw new Exception($e->getMessage() . "\n" . $e->getTraceAsString());
throw new Exception($e->getMessage()."\n".$e->getTraceAsString());
}
}
private function syncSingleUser($userId)
{
$user = User::find($userId);
if (!$user) {
if (! $user) {
throw new Exception("User ID {$userId} nicht gefunden");
}
$this->info("Starte Synchronisierung für User ID {$userId}...");
try {
$this->syncUser($user);
$this->info("✓ Synchronisierung erfolgreich abgeschlossen");
$this->info('✓ Synchronisierung erfolgreich abgeschlossen');
} catch (Exception $e) {
throw new Exception("Fehler bei User ID {$userId}: " . $e->getMessage());
throw new Exception("Fehler bei User ID {$userId}: ".$e->getMessage());
}
}
}
}