mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 12:31:26 -05:00
Refactor: Use RPC for user data
This commit is contained in:
@@ -190,11 +190,11 @@ export const ReportsQueue = forwardRef<ReportsQueueRef>((props, ref) => {
|
||||
// Get unique reporter IDs
|
||||
const reporterIds = [...new Set((data || []).map(r => r.reporter_id))];
|
||||
|
||||
// Fetch reporter profiles
|
||||
const { data: profiles } = await supabase
|
||||
.from('profiles')
|
||||
.select('user_id, username, display_name')
|
||||
.in('user_id', reporterIds);
|
||||
// Fetch reporter profiles with emails (for admins)
|
||||
const { data: allProfiles } = await supabase
|
||||
.rpc('get_users_with_emails');
|
||||
|
||||
const profiles = allProfiles?.filter(p => reporterIds.includes(p.user_id));
|
||||
|
||||
const profileMap = new Map(profiles?.map(p => [p.user_id, p]) || []);
|
||||
|
||||
@@ -219,10 +219,8 @@ export const ReportsQueue = forwardRef<ReportsQueueRef>((props, ref) => {
|
||||
|
||||
profileIds.length > 0
|
||||
? supabase
|
||||
.from('profiles')
|
||||
.select('user_id, username, display_name')
|
||||
.in('user_id', profileIds)
|
||||
.then(({ data }) => data || [])
|
||||
.rpc('get_users_with_emails')
|
||||
.then(({ data }) => data?.filter(p => profileIds.includes(p.user_id)) || [])
|
||||
: Promise.resolve([]),
|
||||
|
||||
submissionIds.length > 0
|
||||
|
||||
Reference in New Issue
Block a user