Warenwirtschaft: Review-Fix — Indizes + schlanke API-Bestellungen-Seite
Indizes auf shopping_orders.shipped/shipped_at/created_at (Board-Filter, Tages-Kacheln) und products.wp_number (SKU-Auflösung). Die API-Bestellungen-Seite lud das komplette JSON-payload für alle 500 Zeilen und serialisierte es in Inline-Attribute; jetzt persistierte positions_count, Liste ohne payload, Inhalt on-demand über show-Endpoint. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
parent
f4256bfc89
commit
50243a07b4
8 changed files with 172 additions and 20 deletions
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Review 20.07.2026: Indizes für die neuen WaWi-Abfragemuster.
|
||||
* - shopping_orders.shipped: Abwicklungs-Board filtert whereIn('shipped', [0,1]).
|
||||
* - shopping_orders.shipped_today/created_today: Tages-Kacheln (whereBetween).
|
||||
* - products.wp_number: SKU-Auflösung der API-Bestellungen (whereWpNumber).
|
||||
* Vorher gab es nur Indizes auf txaction/shipping_option bzw. keinen auf wp_number.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('shopping_orders', function (Blueprint $table) {
|
||||
$table->index('shipped');
|
||||
$table->index('shipped_at');
|
||||
$table->index('created_at');
|
||||
});
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->index('wp_number');
|
||||
});
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('shopping_orders', function (Blueprint $table) {
|
||||
$table->dropIndex(['shipped']);
|
||||
$table->dropIndex(['shipped_at']);
|
||||
$table->dropIndex(['created_at']);
|
||||
});
|
||||
|
||||
Schema::table('products', function (Blueprint $table) {
|
||||
$table->dropIndex(['wp_number']);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
use Illuminate\Database\Migrations\Migration;
|
||||
use Illuminate\Database\Schema\Blueprint;
|
||||
use Illuminate\Support\Facades\DB;
|
||||
use Illuminate\Support\Facades\Schema;
|
||||
|
||||
/**
|
||||
* Review 20.07.2026: Die Übersicht der API-Bestellungen lud für jede Zeile das
|
||||
* komplette JSON-payload nur, um die Positionszahl anzuzeigen (und serialisierte
|
||||
* es zusätzlich in Inline-Attribute). Die Zahl wird jetzt gezählt persistiert,
|
||||
* die Liste kommt ohne payload aus und der Inhalt wird erst im Modal nachgeladen.
|
||||
*/
|
||||
return new class extends Migration
|
||||
{
|
||||
public function up(): void
|
||||
{
|
||||
Schema::table('api_order_logs', function (Blueprint $table) {
|
||||
$table->unsignedSmallInteger('positions_count')->default(0)->after('endpoint');
|
||||
});
|
||||
|
||||
// Backfill aus dem bestehenden payload (Anzahl der Zeilen).
|
||||
foreach (DB::table('api_order_logs')->select('id', 'payload')->cursor() as $row) {
|
||||
$payload = json_decode($row->payload ?? '', true);
|
||||
$count = is_array($payload['lines'] ?? null) ? count($payload['lines']) : 0;
|
||||
DB::table('api_order_logs')->where('id', $row->id)->update(['positions_count' => $count]);
|
||||
}
|
||||
}
|
||||
|
||||
public function down(): void
|
||||
{
|
||||
Schema::table('api_order_logs', function (Blueprint $table) {
|
||||
$table->dropColumn('positions_count');
|
||||
});
|
||||
}
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue