mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-21 04:31:16 -05:00
Refactor: Use RPC for user data
This commit is contained in:
@@ -768,10 +768,10 @@ export async function fetchSystemActivities(
|
||||
const uniqueUserIds = [...new Set(filteredActivities.map(a => a.actor_id).filter(Boolean))] as string[];
|
||||
|
||||
if (uniqueUserIds.length > 0) {
|
||||
const { data: profiles } = await supabase
|
||||
.from('profiles')
|
||||
.select('user_id, username, display_name, avatar_url')
|
||||
.in('user_id', uniqueUserIds);
|
||||
const { data: allProfiles } = await supabase
|
||||
.rpc('get_users_with_emails');
|
||||
|
||||
const profiles = allProfiles?.filter(p => uniqueUserIds.includes(p.user_id));
|
||||
|
||||
if (profiles) {
|
||||
const profileMap = new Map(profiles.map(p => [p.user_id, p]));
|
||||
@@ -797,10 +797,10 @@ export async function fetchSystemActivities(
|
||||
.filter(Boolean) as string[];
|
||||
|
||||
if (targetUserIds.length > 0) {
|
||||
const { data: targetProfiles } = await supabase
|
||||
.from('profiles')
|
||||
.select('user_id, username')
|
||||
.in('user_id', targetUserIds);
|
||||
const { data: allTargetProfiles } = await supabase
|
||||
.rpc('get_users_with_emails');
|
||||
|
||||
const targetProfiles = allTargetProfiles?.filter(p => targetUserIds.includes(p.user_id));
|
||||
|
||||
if (targetProfiles) {
|
||||
const targetProfileMap = new Map(targetProfiles.map(p => [p.user_id, p]));
|
||||
@@ -826,10 +826,10 @@ export async function fetchSystemActivities(
|
||||
.filter(Boolean) as string[];
|
||||
|
||||
if (accountUserIds.length > 0) {
|
||||
const { data: accountProfiles } = await supabase
|
||||
.from('profiles')
|
||||
.select('user_id, username')
|
||||
.in('user_id', accountUserIds);
|
||||
const { data: allAccountProfiles } = await supabase
|
||||
.rpc('get_users_with_emails');
|
||||
|
||||
const accountProfiles = allAccountProfiles?.filter(p => accountUserIds.includes(p.user_id));
|
||||
|
||||
if (accountProfiles) {
|
||||
const accountProfileMap = new Map(accountProfiles.map(p => [p.user_id, p]));
|
||||
|
||||
Reference in New Issue
Block a user