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

@@ -69,7 +69,7 @@ class GroupDiscoveryService
public function publicListing(?User $viewer, string $surface = 'featured', int $page = 1, int $perPage = 24): LengthAwarePaginator
{
$groups = $this->publicGroupBaseQuery()->get();
$groups = $this->publicGroupBaseQuery($viewer)->get();
$sorted = $this->sortGroups($groups, $surface);
$page = max(1, $page);
@@ -89,7 +89,7 @@ class GroupDiscoveryService
public function surfaceCards(?User $viewer = null, string $surface = 'featured', int $limit = 6): array
{
return $this->sortGroups($this->publicGroupBaseQuery()->get(), $surface)
return $this->sortGroups($this->publicGroupBaseQuery($viewer)->get(), $surface)
->take(max(1, $limit))
->map(fn (Group $group): array => $this->cards->mapGroupCard($group, $viewer))
->values()
@@ -104,7 +104,7 @@ class GroupDiscoveryService
return [];
}
$groups = $this->publicGroupBaseQuery()
$groups = $this->publicGroupBaseQuery($viewer)
->where(function (Builder $builder) use ($normalized): void {
$builder->whereRaw('LOWER(name) LIKE ?', ['%' . $normalized . '%'])
->orWhereRaw('LOWER(slug) LIKE ?', ['%' . $normalized . '%'])
@@ -191,9 +191,9 @@ class GroupDiscoveryService
];
}
private function publicGroupBaseQuery(): Builder
private function publicGroupBaseQuery(?User $viewer = null): Builder
{
return Group::query()
$query = Group::query()
->with(['owner.profile', 'recruitmentProfile', 'discoveryMetric', 'members', 'badges'])
->withCount([
'members as active_members_count' => fn (Builder $query) => $query->where('status', Group::STATUS_ACTIVE),
@@ -203,7 +203,9 @@ class GroupDiscoveryService
'releases as recent_public_releases_count' => fn (Builder $query) => $query
->where('visibility', GroupRelease::VISIBILITY_PUBLIC)
->where('status', GroupRelease::STATUS_RELEASED)
->where('released_at', '>=', now()->subDays(60)),
->where('released_at', '>=', now()->subDays(45)),
'artworks as approved_group_artworks_count' => fn (Builder $query) => $query
->where('group_review_status', 'approved'),
'projects as public_projects_count' => fn (Builder $query) => $query
->where('visibility', GroupProject::VISIBILITY_PUBLIC)
->whereIn('status', [GroupProject::STATUS_ACTIVE, GroupProject::STATUS_REVIEW, GroupProject::STATUS_RELEASED]),
@@ -225,6 +227,14 @@ class GroupDiscoveryService
->where('status', GroupRelease::STATUS_RELEASED),
], 'released_at')
->public();
if ($viewer) {
$query->withExists([
'follows as viewer_is_following' => fn (Builder $followQuery) => $followQuery->where('user_id', $viewer->id),
]);
}
return $query;
}
private function sortGroups(Collection $groups, string $surface): Collection