From e06a382c948101ba07482ea85fa696e4abf8130a Mon Sep 17 00:00:00 2001 From: MartinBraquet Date: Mon, 20 Oct 2025 16:01:33 +0200 Subject: [PATCH] Rename love_ships --- backend/api/src/get-likes-and-ships.ts | 16 ++++++------ backend/api/src/ship-profiles.ts | 6 ++--- .../shared/src/create-love-notification.ts | 8 +++--- backend/supabase/love_ships.sql | 25 ------------------- backend/supabase/migration.sql | 2 +- backend/supabase/profile_ships.sql | 25 +++++++++++++++++++ common/src/notifications.ts | 2 +- common/src/supabase/schema.ts | 2 +- common/src/user-notification-preferences.ts | 4 +-- web/components/notification-items.tsx | 2 +- web/hooks/use-notifications.ts | 4 +-- web/pages/notifications.tsx | 2 +- 12 files changed, 49 insertions(+), 49 deletions(-) delete mode 100644 backend/supabase/love_ships.sql create mode 100644 backend/supabase/profile_ships.sql diff --git a/backend/api/src/get-likes-and-ships.ts b/backend/api/src/get-likes-and-ships.ts index 5c9bf7ab..4d257125 100644 --- a/backend/api/src/get-likes-and-ships.ts +++ b/backend/api/src/get-likes-and-ships.ts @@ -68,11 +68,11 @@ export const getLikesAndShipsMain = async (userId: string) => { }>( ` select - target1_id, target2_id, creator_id, love_ships.created_time, + target1_id, target2_id, creator_id, profile_ships.created_time, target1_id as target_id - from love_ships - join profiles on profiles.user_id = love_ships.target1_id - join users on users.id = love_ships.target1_id + from profile_ships + join profiles on profiles.user_id = profile_ships.target1_id + join users on users.id = profile_ships.target1_id where target2_id = $1 and profiles.looking_for_matches and profiles.pinned_url is not null @@ -81,11 +81,11 @@ export const getLikesAndShipsMain = async (userId: string) => { union all select - target1_id, target2_id, creator_id, love_ships.created_time, + target1_id, target2_id, creator_id, profile_ships.created_time, target2_id as target_id - from love_ships - join profiles on profiles.user_id = love_ships.target2_id - join users on users.id = love_ships.target2_id + from profile_ships + join profiles on profiles.user_id = profile_ships.target2_id + join users on users.id = profile_ships.target2_id where target1_id = $1 and profiles.looking_for_matches and profiles.pinned_url is not null diff --git a/backend/api/src/ship-profiles.ts b/backend/api/src/ship-profiles.ts index 65a0a40d..583fdda2 100644 --- a/backend/api/src/ship-profiles.ts +++ b/backend/api/src/ship-profiles.ts @@ -14,7 +14,7 @@ export const shipProfiles: APIHandler<'ship-profiles'> = async (props, auth) => // Check if ship already exists or with swapped target IDs const existing = await tryCatch( pg.oneOrNone<{ ship_id: string }>( - `select ship_id from love_ships + `select ship_id from profile_ships where creator_id = $1 and ( target1_id = $2 and target2_id = $3 @@ -33,7 +33,7 @@ export const shipProfiles: APIHandler<'ship-profiles'> = async (props, auth) => if (existing.data) { if (remove) { const { error } = await tryCatch( - pg.none('delete from love_ships where ship_id = $1', [ + pg.none('delete from profile_ships where ship_id = $1', [ existing.data.ship_id, ]) ) @@ -48,7 +48,7 @@ export const shipProfiles: APIHandler<'ship-profiles'> = async (props, auth) => // Insert the new ship const { data, error } = await tryCatch( - insert(pg, 'love_ships', { + insert(pg, 'profile_ships', { creator_id: creatorId, target1_id: targetUserId1, target2_id: targetUserId2, diff --git a/backend/shared/src/create-love-notification.ts b/backend/shared/src/create-love-notification.ts index 8f19bab7..97c906b1 100644 --- a/backend/shared/src/create-love-notification.ts +++ b/backend/shared/src/create-love-notification.ts @@ -40,7 +40,7 @@ export const createProfileLikeNotification = async (like: Row<'profile_likes'>) } export const createLoveShipNotification = async ( - ship: Row<'love_ships'>, + ship: Row<'profile_ships'>, recipientId: string ) => { const { creator_id, target1_id, target2_id, ship_id } = ship @@ -61,7 +61,7 @@ export const createLoveShipNotification = async ( const { sendToBrowser } = getNotificationDestinationsForUser( targetPrivateUser, - 'new_love_ship' + 'new_profile_ship' ) if (!sendToBrowser) return @@ -69,11 +69,11 @@ export const createLoveShipNotification = async ( const notification: Notification = { id, userId: recipientId, - reason: 'new_love_ship', + reason: 'new_profile_ship', createdTime: Date.now(), isSeen: false, sourceId: ship_id, - sourceType: 'love_ship', + sourceType: 'profile_ship', sourceUpdateType: 'created', sourceUserName: profile.user.name, sourceUserUsername: profile.user.username, diff --git a/backend/supabase/love_ships.sql b/backend/supabase/love_ships.sql deleted file mode 100644 index f64cdb44..00000000 --- a/backend/supabase/love_ships.sql +++ /dev/null @@ -1,25 +0,0 @@ -CREATE TABLE IF NOT EXISTS love_ships ( - created_time TIMESTAMPTZ DEFAULT now() NOT NULL, - creator_id TEXT NOT NULL, - ship_id TEXT DEFAULT random_alphanumeric(12) NOT NULL, - target1_id TEXT NOT NULL, - target2_id TEXT NOT NULL, - CONSTRAINT love_ships_pkey PRIMARY KEY (creator_id, ship_id) -); - --- Row Level Security -ALTER TABLE love_ships ENABLE ROW LEVEL SECURITY; - --- Policies -DROP POLICY IF EXISTS "public read" ON love_ships; -CREATE POLICY "public read" ON love_ships -FOR SELECT USING (true); - --- Indexes --- Primary key automatically creates a unique index on (creator_id, ship_id), so no need to recreate it. --- Keep additional indexes for query optimization: -DROP INDEX IF EXISTS love_ships_target1_id; -CREATE INDEX love_ships_target1_id ON public.love_ships USING btree (target1_id); - -DROP INDEX IF EXISTS love_ships_target2_id; -CREATE INDEX love_ships_target2_id ON public.love_ships USING btree (target2_id); diff --git a/backend/supabase/migration.sql b/backend/supabase/migration.sql index 0ceac932..e8b0c4c2 100644 --- a/backend/supabase/migration.sql +++ b/backend/supabase/migration.sql @@ -13,7 +13,7 @@ BEGIN; \i backend/supabase/compatibility_answers.sql \i backend/supabase/profile_likes.sql \i backend/supabase/compatibility_prompts.sql -\i backend/supabase/love_ships.sql +\i backend/supabase/profile_ships.sql \i backend/supabase/love_stars.sql \i backend/supabase/love_waitlist.sql \i backend/supabase/user_events.sql diff --git a/backend/supabase/profile_ships.sql b/backend/supabase/profile_ships.sql new file mode 100644 index 00000000..60396542 --- /dev/null +++ b/backend/supabase/profile_ships.sql @@ -0,0 +1,25 @@ +CREATE TABLE IF NOT EXISTS profile_ships ( + created_time TIMESTAMPTZ DEFAULT now() NOT NULL, + creator_id TEXT NOT NULL, + ship_id TEXT DEFAULT random_alphanumeric(12) NOT NULL, + target1_id TEXT NOT NULL, + target2_id TEXT NOT NULL, + CONSTRAINT profile_ships_pkey PRIMARY KEY (creator_id, ship_id) +); + +-- Row Level Security +ALTER TABLE profile_ships ENABLE ROW LEVEL SECURITY; + +-- Policies +DROP POLICY IF EXISTS "public read" ON profile_ships; +CREATE POLICY "public read" ON profile_ships +FOR SELECT USING (true); + +-- Indexes +-- Primary key automatically creates a unique index on (creator_id, ship_id), so no need to recreate it. +-- Keep additional indexes for query optimization: +DROP INDEX IF EXISTS profile_ships_target1_id; +CREATE INDEX profile_ships_target1_id ON public.profile_ships USING btree (target1_id); + +DROP INDEX IF EXISTS profile_ships_target2_id; +CREATE INDEX profile_ships_target2_id ON public.profile_ships USING btree (target2_id); diff --git a/common/src/notifications.ts b/common/src/notifications.ts index a7e92675..53053a38 100644 --- a/common/src/notifications.ts +++ b/common/src/notifications.ts @@ -33,7 +33,7 @@ export const NOTIFICATION_TYPES_TO_SELECT = [ 'new_match', // new match markets 'comment_on_profile', // endorsements 'profile_like', - 'love_ship', + 'profile_ship', ] export const NOTIFICATIONS_PER_PAGE = 30 diff --git a/common/src/supabase/schema.ts b/common/src/supabase/schema.ts index 02e1fc9b..af717714 100644 --- a/common/src/supabase/schema.ts +++ b/common/src/supabase/schema.ts @@ -187,7 +187,7 @@ export type Database = { } Relationships: [] } - love_ships: { + profile_ships: { Row: { created_time: string creator_id: string diff --git a/common/src/user-notification-preferences.ts b/common/src/user-notification-preferences.ts index d8f623b8..bee19e3f 100644 --- a/common/src/user-notification-preferences.ts +++ b/common/src/user-notification-preferences.ts @@ -7,7 +7,7 @@ export type notification_preferences = { new_match: notification_destination_types[] new_endorsement: notification_destination_types[] new_profile_like: notification_destination_types[] - new_love_ship: notification_destination_types[] + new_profile_ship: notification_destination_types[] new_search_alerts: notification_destination_types[] // User-related @@ -41,7 +41,7 @@ export const getDefaultNotificationPreferences = (isDev?: boolean) => { new_search_alerts: constructPref(true, true, true), new_endorsement: constructPref(true, true, true), new_profile_like: constructPref(true, false, false), - new_love_ship: constructPref(true, false, false), + new_profile_ship: constructPref(true, false, false), // User-related new_message: constructPref(true, true, true), diff --git a/web/components/notification-items.tsx b/web/components/notification-items.tsx index 1682dba5..36083905 100644 --- a/web/components/notification-items.tsx +++ b/web/components/notification-items.tsx @@ -32,7 +32,7 @@ export function NotificationItem(props: { notification: Notification }) { return } else if (reason === 'new_profile_like') { return - } else if (reason === 'new_love_ship') { + } else if (reason === 'new_profile_ship') { return } else { return <>unknown notification: {sourceType} diff --git a/web/hooks/use-notifications.ts b/web/hooks/use-notifications.ts index 680dfa36..f9676121 100644 --- a/web/hooks/use-notifications.ts +++ b/web/hooks/use-notifications.ts @@ -55,8 +55,8 @@ function groupGeneralNotifications( ? 'quest_payout' : n.sourceType === 'profile_like' ? 'profile_like' - : n.sourceType === 'love_ship' - ? 'love_ship' + : n.sourceType === 'profile_ship' + ? 'profile_ship' : n.data?.isPartner ? 'isPartner' : 'unknown') diff --git a/web/pages/notifications.tsx b/web/pages/notifications.tsx index 0efad59b..a5bfb4b5 100644 --- a/web/pages/notifications.tsx +++ b/web/pages/notifications.tsx @@ -168,7 +168,7 @@ const LoadedNotificationSettings = (props: { privateUser: PrivateUser }) => { question: '... endorses you?', }, { - type: 'new_love_ship', + type: 'new_profile_ship', question: '... ships you?', }, {