Rename love_ships

This commit is contained in:
MartinBraquet
2025-10-20 16:01:33 +02:00
parent d1a421ca15
commit e06a382c94
12 changed files with 49 additions and 49 deletions

View File

@@ -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

View File

@@ -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,

View File

@@ -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,

View File

@@ -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);

View File

@@ -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

View File

@@ -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);

View File

@@ -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

View File

@@ -187,7 +187,7 @@ export type Database = {
}
Relationships: []
}
love_ships: {
profile_ships: {
Row: {
created_time: string
creator_id: string

View File

@@ -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),

View File

@@ -32,7 +32,7 @@ export function NotificationItem(props: { notification: Notification }) {
return <NewMatchNotification {...params} />
} else if (reason === 'new_profile_like') {
return <ProfileLikeNotification {...params} />
} else if (reason === 'new_love_ship') {
} else if (reason === 'new_profile_ship') {
return <LoveShipNotification {...params} />
} else {
return <>unknown notification: {sourceType}</>

View File

@@ -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')

View File

@@ -168,7 +168,7 @@ const LoadedNotificationSettings = (props: { privateUser: PrivateUser }) => {
question: '... endorses you?',
},
{
type: 'new_love_ship',
type: 'new_profile_ship',
question: '... ships you?',
},
{