optimizations
This commit is contained in:
@@ -24,7 +24,10 @@ use App\Services\AvatarService;
|
||||
use App\Services\ArtworkService;
|
||||
use App\Services\FollowService;
|
||||
use App\Services\AchievementService;
|
||||
use App\Services\CollectionService;
|
||||
use App\Services\FollowAnalyticsService;
|
||||
use App\Services\LeaderboardService;
|
||||
use App\Services\UserSuggestionService;
|
||||
use App\Services\Countries\CountryCatalogService;
|
||||
use App\Services\ThumbnailPresenter;
|
||||
use App\Services\ThumbnailService;
|
||||
@@ -69,8 +72,11 @@ class ProfileController extends Controller
|
||||
private readonly CaptchaVerifier $captchaVerifier,
|
||||
private readonly XPService $xp,
|
||||
private readonly AchievementService $achievements,
|
||||
private readonly CollectionService $collections,
|
||||
private readonly FollowAnalyticsService $followAnalytics,
|
||||
private readonly LeaderboardService $leaderboards,
|
||||
private readonly CountryCatalogService $countryCatalog,
|
||||
private readonly UserSuggestionService $userSuggestions,
|
||||
)
|
||||
{
|
||||
}
|
||||
@@ -1003,9 +1009,11 @@ class ProfileController extends Controller
|
||||
$followerCount = 0;
|
||||
$recentFollowers = collect();
|
||||
$viewerIsFollowing = false;
|
||||
$followingCount = 0;
|
||||
|
||||
if (Schema::hasTable('user_followers')) {
|
||||
$followerCount = DB::table('user_followers')->where('user_id', $user->id)->count();
|
||||
$followingCount = DB::table('user_followers')->where('follower_id', $user->id)->count();
|
||||
|
||||
$recentFollowers = DB::table('user_followers as uf')
|
||||
->join('users as u', 'u.id', '=', 'uf.follower_id')
|
||||
@@ -1033,6 +1041,30 @@ class ProfileController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
$liveUploadsCount = 0;
|
||||
if (Schema::hasTable('artworks')) {
|
||||
$liveUploadsCount = (int) DB::table('artworks')
|
||||
->where('user_id', $user->id)
|
||||
->whereNull('deleted_at')
|
||||
->count();
|
||||
}
|
||||
|
||||
$liveAwardsReceivedCount = 0;
|
||||
if (Schema::hasTable('artwork_awards') && Schema::hasTable('artworks')) {
|
||||
$liveAwardsReceivedCount = (int) DB::table('artwork_awards as aw')
|
||||
->join('artworks as a', 'a.id', '=', 'aw.artwork_id')
|
||||
->where('a.user_id', $user->id)
|
||||
->whereNull('a.deleted_at')
|
||||
->count();
|
||||
}
|
||||
|
||||
$statsPayload = array_merge($stats ? (array) $stats : [], [
|
||||
'uploads_count' => $liveUploadsCount,
|
||||
'awards_received_count' => $liveAwardsReceivedCount,
|
||||
'followers_count' => (int) $followerCount,
|
||||
'following_count' => (int) $followingCount,
|
||||
]);
|
||||
|
||||
// ── Profile comments ─────────────────────────────────────────────────
|
||||
$profileComments = collect();
|
||||
if (Schema::hasTable('profile_comments')) {
|
||||
@@ -1066,6 +1098,11 @@ class ProfileController extends Controller
|
||||
}
|
||||
|
||||
$xpSummary = $this->xp->summary((int) $user->id);
|
||||
$followContext = $viewer && $viewer->id !== $user->id
|
||||
? $this->followService->relationshipContext((int) $viewer->id, (int) $user->id)
|
||||
: null;
|
||||
$followAnalytics = $this->followAnalytics->summaryForUser((int) $user->id, $followerCount);
|
||||
$suggestedUsers = $viewer ? $this->userSuggestions->suggestFor($viewer, 4) : [];
|
||||
|
||||
$creatorStories = Story::query()
|
||||
->published()
|
||||
@@ -1100,6 +1137,9 @@ class ProfileController extends Controller
|
||||
'published_at' => $story->published_at?->toISOString(),
|
||||
]);
|
||||
|
||||
$profileCollections = $this->collections->getProfileCollections($user, $viewer);
|
||||
$profileCollectionsPayload = $this->collections->mapCollectionCardPayloads($profileCollections, $isOwner);
|
||||
|
||||
// ── Profile data ─────────────────────────────────────────────────────
|
||||
$profile = $user->profile;
|
||||
$country = $this->countryCatalog->resolveUserCountry($user);
|
||||
@@ -1193,14 +1233,18 @@ class ProfileController extends Controller
|
||||
'artworks' => $artworkPayload,
|
||||
'featuredArtworks' => $featuredArtworks->values(),
|
||||
'favourites' => $favourites,
|
||||
'stats' => $stats,
|
||||
'stats' => $statsPayload,
|
||||
'socialLinks' => $socialLinks,
|
||||
'followerCount' => $followerCount,
|
||||
'recentFollowers' => $recentFollowers->values(),
|
||||
'followContext' => $followContext,
|
||||
'followAnalytics' => $followAnalytics,
|
||||
'suggestedUsers' => $suggestedUsers,
|
||||
'viewerIsFollowing' => $viewerIsFollowing,
|
||||
'heroBgUrl' => $heroBgUrl,
|
||||
'profileComments' => $profileComments->values(),
|
||||
'creatorStories' => $creatorStories->values(),
|
||||
'collections' => $profileCollectionsPayload,
|
||||
'achievements' => $achievementSummary,
|
||||
'leaderboardRank' => $leaderboardRank,
|
||||
'countryName' => $countryName,
|
||||
@@ -1209,6 +1253,10 @@ class ProfileController extends Controller
|
||||
'initialTab' => $resolvedInitialTab,
|
||||
'profileUrl' => $canonical,
|
||||
'galleryUrl' => $galleryUrl,
|
||||
'collectionCreateUrl' => $isOwner ? route('settings.collections.create') : null,
|
||||
'collectionReorderUrl' => $isOwner ? route('settings.collections.reorder-profile') : null,
|
||||
'collectionsFeaturedUrl' => route('collections.featured'),
|
||||
'collectionFeatureLimit' => (int) config('collections.featured_limit', 3),
|
||||
'profileTabUrls' => $profileTabUrls,
|
||||
])->withViewData([
|
||||
'page_title' => $galleryOnly
|
||||
|
||||
Reference in New Issue
Block a user