Fix minor enhancement opportunities

This commit is contained in:
gpt-engineer-app[bot]
2025-10-30 23:47:14 +00:00
parent b4ecc8ef13
commit 8f4110d890
3 changed files with 33 additions and 47 deletions

View File

@@ -33,42 +33,39 @@ export function useProfileActivity(
return [];
}
// Build queries with conditional filters
const reviewsQuery = supabase.from('reviews')
.select('id, rating, title, created_at, moderation_status, park_id, ride_id, parks(name, slug), rides(name, slug, parks(name, slug))')
.eq('user_id', userId);
if (!isOwnProfile && !isModerator) {
reviewsQuery.eq('moderation_status', 'approved');
}
const submissionsQuery = supabase.from('content_submissions')
.select('id, submission_type, content, status, created_at')
.eq('user_id', userId);
if (!isOwnProfile && !isModerator) {
submissionsQuery.eq('status', 'approved');
}
const rankingsQuery = supabase.from('user_top_lists')
.select('id, title, description, list_type, created_at')
.eq('user_id', userId);
if (!isOwnProfile) {
rankingsQuery.eq('is_public', true);
}
// Fetch all activity types in parallel
const [reviews, credits, submissions, rankings] = await Promise.all([
// Reviews query
supabase.from('reviews')
.select('id, rating, title, created_at, moderation_status, park_id, ride_id, parks(name, slug), rides(name, slug, parks(name, slug))')
.eq('user_id', userId)
.eq('moderation_status', isOwnProfile || isModerator ? undefined : 'approved')
.order('created_at', { ascending: false })
.limit(10)
.then(res => res.data || []),
// Credits query
reviewsQuery.order('created_at', { ascending: false }).limit(10).then(res => res.data || []),
supabase.from('user_ride_credits')
.select('id, ride_count, first_ride_date, created_at, rides(name, slug, parks(name, slug))')
.eq('user_id', userId)
.order('created_at', { ascending: false })
.limit(10)
.then(res => res.data || []),
// Submissions query
supabase.from('content_submissions')
.select('id, submission_type, content, status, created_at')
.eq('user_id', userId)
.eq('status', isOwnProfile || isModerator ? undefined : 'approved')
.order('created_at', { ascending: false })
.limit(10)
.then(res => res.data || []),
// Rankings query
supabase.from('user_top_lists')
.select('id, title, description, list_type, created_at')
.eq('user_id', userId)
.eq('is_public', isOwnProfile ? undefined : true)
.order('created_at', { ascending: false })
.limit(10)
.then(res => res.data || [])
submissionsQuery.order('created_at', { ascending: false }).limit(10).then(res => res.data || []),
rankingsQuery.order('created_at', { ascending: false }).limit(10).then(res => res.data || [])
]);
// Enrich photo submissions in batch