Optimierung 5.1: Tabellen-Concerns (Sortierung, Volltext-Heuristik, Stats)
- HasSortableTable::sort() ersetzt 5 byte-identische sort()-Kopien in den Admin-Listen (Benutzer, Firmen, Kategorien, Kontakte, Pressemitteilungen). $sortBy/$sortDir-Defaults bleiben je Komponente, da sie divergieren. - HasFullTextSearch::supportsFullTextSearch() ersetzt 9 byte-identische Kopien (4 Index-Listen + 5 Firmen-Comboboxen); ungenutzte DB-Imports entfernt. - AdminPerformanceCache::activeInactiveStats(Builder) buendelt den identischen SUM(CASE WHEN is_active)-Block der Benutzer- und Firmenliste. Zurueckgestellt (real divergent): HasResettableFilters (updatedXxxFilter normalisieren teils zusaetzlich) und eine gemeinsame hydrateRelationCounts(). Tests: erweiterte AdminPerformanceCacheTest; 99 Admin-Tests bleiben gruen. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
8e0aedaf95
commit
a8958c176e
15 changed files with 111 additions and 145 deletions
|
|
@ -5,6 +5,19 @@ use App\Services\Admin\AdminPerformanceCache;
|
|||
use Illuminate\Support\Facades\Cache;
|
||||
use Spatie\Permission\Models\Role;
|
||||
|
||||
test('activeInactiveStats aggregates total, active and inactive in one shape', function () {
|
||||
Company::factory()->count(2)->create(['is_active' => true]);
|
||||
Company::factory()->create(['is_active' => false]);
|
||||
|
||||
$stats = app(AdminPerformanceCache::class)->activeInactiveStats(Company::query());
|
||||
|
||||
expect($stats)->toBe([
|
||||
'total' => 3,
|
||||
'active' => 2,
|
||||
'inactive' => 1,
|
||||
]);
|
||||
});
|
||||
|
||||
test('admin performance cache is flushed when observed models change', function () {
|
||||
Cache::put(AdminPerformanceCache::DashboardStats, ['stale' => true], 600);
|
||||
Cache::put(AdminPerformanceCache::PressReleaseStats, ['stale' => true], 600);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue