Wire admin studio SSR and search infrastructure

This commit is contained in:
2026-05-01 11:46:06 +02:00
parent 257b0dbef6
commit 18cea8b0f0
329 changed files with 197465 additions and 2741 deletions

View File

@@ -204,17 +204,22 @@ class UserPreferenceBuilder
return [];
}
// Sample recent artworks to avoid full scan
$rows = DB::table('artworks as a')
->join('artwork_tag as at', 'at.artwork_id', '=', 'a.id')
->join('tags as t', 't.id', '=', 'at.tag_id')
->whereIn('a.user_id', $creatorIds)
->where('a.is_public', true)
->where('a.is_approved', true)
->where('t.is_active', true)
->whereNull('a.deleted_at')
->orderByDesc('a.published_at')
// Sample the 500 most-recent artworks first (subquery), then count tags.
// ORDER BY must not appear on a non-aggregated column inside GROUP BY
// (MySQL only_full_group_by mode rejects it).
$recentIds = DB::table('artworks')
->whereIn('user_id', $creatorIds)
->where('is_public', true)
->where('is_approved', true)
->whereNull('deleted_at')
->orderByDesc('published_at')
->limit(500)
->select('id');
$rows = DB::table('artwork_tag as at')
->joinSub($recentIds, 'a', 'a.id', '=', 'at.artwork_id')
->join('tags as t', 't.id', '=', 'at.tag_id')
->where('t.is_active', true)
->selectRaw('t.slug, COUNT(*) as cnt')
->groupBy('t.id', 't.slug')
->get();