mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-23 05:31:16 -05:00
Fix: Correct Novu migration utility query
This commit is contained in:
@@ -28,16 +28,25 @@ export function NovuMigrationUtility() {
|
||||
setProgress(0);
|
||||
|
||||
try {
|
||||
// First, fetch user IDs that already have Novu subscriber IDs
|
||||
const { data: existingPrefs, error: prefsError } = await supabase
|
||||
.from('user_notification_preferences')
|
||||
.select('user_id')
|
||||
.not('novu_subscriber_id', 'is', null);
|
||||
|
||||
if (prefsError) throw prefsError;
|
||||
|
||||
const existingUserIds = existingPrefs?.map(p => p.user_id) || [];
|
||||
|
||||
// Fetch users without Novu subscriber IDs
|
||||
const { data: users, error: fetchError } = await supabase
|
||||
const query = supabase
|
||||
.from('profiles')
|
||||
.select('user_id, users:user_id(email)')
|
||||
.not('user_id', 'in',
|
||||
supabase
|
||||
.from('user_notification_preferences')
|
||||
.select('user_id')
|
||||
.not('novu_subscriber_id', 'is', null)
|
||||
);
|
||||
.select('user_id, users:user_id(email)');
|
||||
|
||||
// Only add the not filter if there are existing user IDs
|
||||
const { data: users, error: fetchError } = existingUserIds.length > 0
|
||||
? await query.not('user_id', 'in', `(${existingUserIds.join(',')})`)
|
||||
: await query;
|
||||
|
||||
if (fetchError) throw fetchError;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user