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

@@ -38,9 +38,11 @@ use App\Services\UserSuggestionService;
use App\Services\Countries\CountryCatalogService;
use App\Services\Maturity\ArtworkMaturityService;
use App\Services\ThumbnailPresenter;
use App\Services\Worlds\WorldRewardService;
use App\Services\XPService;
use App\Services\UsernameApprovalService;
use App\Services\Profile\CreatorJourneyService;
use App\Services\Profile\WorldProfileHistoryService;
use App\Services\UserStatsService;
use App\Support\AvatarUrl;
use App\Support\CoverUrl;
@@ -66,6 +68,7 @@ class ProfileController extends Controller
'artworks',
'stories',
'achievements',
'worlds',
'collections',
'about',
'stats',
@@ -87,6 +90,8 @@ class ProfileController extends Controller
private readonly CountryCatalogService $countryCatalog,
private readonly UserSuggestionService $userSuggestions,
private readonly CreatorJourneyService $creatorJourney,
private readonly WorldRewardService $worldRewards,
private readonly WorldProfileHistoryService $worldProfileHistory,
)
{
}
@@ -1267,6 +1272,10 @@ class ProfileController extends Controller
->mapWithKeys(fn (string $tab) => [$tab => url('/@' . $usernameSlug . '/' . $tab)])
->all();
$achievementSummary = $this->achievements->summary((int) $user->id);
$worldRewardSummary = $this->worldRewards->summaryForUser($user);
$worldHistory = $isOwner
? $this->worldProfileHistory->ownerPayloadForUser($user)
: $this->worldProfileHistory->publicPayloadForUser($user);
$leaderboardRank = $this->leaderboards->creatorRankSummary((int) $user->id);
$groupContributionHistory = $this->buildGroupContributionHistory($user);
$journey = $this->creatorJourney->publicPayloadForUser($user);
@@ -1342,6 +1351,8 @@ class ProfileController extends Controller
'creatorStories' => $creatorStories->values(),
'collections' => $profileCollectionsPayload,
'achievements' => $achievementSummary,
'worldRewards' => $worldRewardSummary,
'worldHistory' => $worldHistory,
'leaderboardRank' => $leaderboardRank,
'journey' => $journey,
'groupContributionHistory' => $groupContributionHistory,

View File

@@ -3,10 +3,10 @@
namespace App\Http\Controllers\User;
use App\Http\Controllers\Controller;
use Illuminate\Http\Request;
use App\Models\ArtworkDownload;
use Illuminate\Support\Str;
use Carbon\Carbon;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
class TodayDownloadsController extends Controller
{
@@ -15,20 +15,40 @@ class TodayDownloadsController extends Controller
$hits = 30;
$today = Carbon::now()->toDateString();
$artworkVisibilityScope = function ($q) {
$q->public()->published()->whereNull('deleted_at');
};
$hasTodayDownloads = ArtworkDownload::query()
->whereHas('artwork', $artworkVisibilityScope)
->whereDate('created_at', $today)
->exists();
$query = ArtworkDownload::with([
'artwork.user:id,name,username',
'artwork.user.profile:user_id,avatar_hash',
'artwork.categories:id,name,slug',
])
->whereDate('created_at', $today)
->whereHas('artwork', function ($q) {
$q->public()->published()->whereNull('deleted_at');
})
->whereHas('artwork', $artworkVisibilityScope)
->selectRaw('artwork_id, COUNT(*) as num_downloads')
->groupBy('artwork_id')
->orderByDesc('num_downloads');
if ($hasTodayDownloads) {
$query->whereDate('created_at', $today);
} else {
$fallbackDownloadIds = ArtworkDownload::query()
->whereHas('artwork', $artworkVisibilityScope)
->orderByDesc('created_at')
->limit(1000)
->pluck('id');
if ($fallbackDownloadIds->isEmpty()) {
$query->whereRaw('1 = 0');
} else {
$query->whereIn('id', $fallbackDownloadIds->all());
}
}
$paginator = $query->paginate($hits)->withQueryString();
$paginator->getCollection()->transform(function ($row) {
@@ -61,7 +81,7 @@ class TodayDownloadsController extends Controller
$categoryId = $primaryCategory->id ?? null;
$categoryName = $primaryCategory->name ?? '';
$categorySlug = $primaryCategory->slug ?? '';
$avatarHash = $art->user->profile->avatar_hash ?? null;
$avatarHash = $art->user?->profile?->avatar_hash;
return (object) [
'id' => $art->id ?? null,
@@ -87,8 +107,15 @@ class TodayDownloadsController extends Controller
];
});
$page_title = 'Today Downloaded Artworks';
$page_title = $hasTodayDownloads
? 'Today Downloaded Artworks'
: 'Most Downloaded from Latest 1000 Downloads';
return view('web.downloads.today', ['page_title' => $page_title, 'artworks' => $paginator]);
return view('web.downloads.today', [
'page_title' => $page_title,
'artworks' => $paginator,
'display_date' => $today,
'is_fallback_window' => ! $hasTodayDownloads,
]);
}
}