mirror of
https://github.com/CompassConnections/Compass.git
synced 2026-04-10 17:48:41 -04:00
Rename love_likes
This commit is contained in:
@@ -20,10 +20,10 @@ export const getLikesAndShipsMain = async (userId: string) => {
|
||||
created_time: number
|
||||
}>(
|
||||
`
|
||||
select target_id, love_likes.created_time
|
||||
from love_likes
|
||||
join profiles on profiles.user_id = love_likes.target_id
|
||||
join users on users.id = love_likes.target_id
|
||||
select target_id, profile_likes.created_time
|
||||
from profile_likes
|
||||
join profiles on profiles.user_id = profile_likes.target_id
|
||||
join users on users.id = profile_likes.target_id
|
||||
where creator_id = $1
|
||||
and looking_for_matches
|
||||
and profiles.pinned_url is not null
|
||||
@@ -42,10 +42,10 @@ export const getLikesAndShipsMain = async (userId: string) => {
|
||||
created_time: number
|
||||
}>(
|
||||
`
|
||||
select creator_id, love_likes.created_time
|
||||
from love_likes
|
||||
join profiles on profiles.user_id = love_likes.creator_id
|
||||
join users on users.id = love_likes.creator_id
|
||||
select creator_id, profile_likes.created_time
|
||||
from profile_likes
|
||||
join profiles on profiles.user_id = profile_likes.creator_id
|
||||
join users on users.id = profile_likes.creator_id
|
||||
where target_id = $1
|
||||
and looking_for_matches
|
||||
and profiles.pinned_url is not null
|
||||
|
||||
@@ -17,7 +17,7 @@ export const getHasFreeLike = async (userId: string) => {
|
||||
const likeGivenToday = await pg.oneOrNone<object>(
|
||||
`
|
||||
select 1
|
||||
from love_likes
|
||||
from profile_likes
|
||||
where creator_id = $1
|
||||
and created_time at time zone 'UTC' at time zone 'America/Los_Angeles' >= (now() at time zone 'UTC' at time zone 'America/Los_Angeles')::date
|
||||
and created_time at time zone 'UTC' at time zone 'America/Los_Angeles' < ((now() at time zone 'UTC' at time zone 'America/Los_Angeles')::date + interval '1 day')
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createSupabaseDirectClient } from 'shared/supabase/init'
|
||||
import { APIError, APIHandler } from './helpers/endpoint'
|
||||
import { createLoveLikeNotification } from 'shared/create-love-notification'
|
||||
import { createProfileLikeNotification } from 'shared/create-love-notification'
|
||||
import { getHasFreeLike } from './has-free-like'
|
||||
import { log } from 'shared/utils'
|
||||
import { tryCatch } from 'common/util/try-catch'
|
||||
@@ -15,7 +15,7 @@ export const likeProfile: APIHandler<'like-profile'> = async (props, auth) => {
|
||||
if (remove) {
|
||||
const { error } = await tryCatch(
|
||||
pg.none(
|
||||
'delete from love_likes where creator_id = $1 and target_id = $2',
|
||||
'delete from profile_likes where creator_id = $1 and target_id = $2',
|
||||
[creatorId, targetUserId]
|
||||
)
|
||||
)
|
||||
@@ -28,8 +28,8 @@ export const likeProfile: APIHandler<'like-profile'> = async (props, auth) => {
|
||||
|
||||
// Check if like already exists
|
||||
const { data: existing } = await tryCatch(
|
||||
pg.oneOrNone<Row<'love_likes'>>(
|
||||
'select * from love_likes where creator_id = $1 and target_id = $2',
|
||||
pg.oneOrNone<Row<'profile_likes'>>(
|
||||
'select * from profile_likes where creator_id = $1 and target_id = $2',
|
||||
[creatorId, targetUserId]
|
||||
)
|
||||
)
|
||||
@@ -48,8 +48,8 @@ export const likeProfile: APIHandler<'like-profile'> = async (props, auth) => {
|
||||
|
||||
// Insert the new like
|
||||
const { data, error } = await tryCatch(
|
||||
pg.one<Row<'love_likes'>>(
|
||||
'insert into love_likes (creator_id, target_id) values ($1, $2) returning *',
|
||||
pg.one<Row<'profile_likes'>>(
|
||||
'insert into profile_likes (creator_id, target_id) values ($1, $2) returning *',
|
||||
[creatorId, targetUserId]
|
||||
)
|
||||
)
|
||||
@@ -59,7 +59,7 @@ export const likeProfile: APIHandler<'like-profile'> = async (props, auth) => {
|
||||
}
|
||||
|
||||
const continuation = async () => {
|
||||
await createLoveLikeNotification(data)
|
||||
await createProfileLikeNotification(data)
|
||||
}
|
||||
|
||||
return {
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Notification } from 'common/notifications'
|
||||
import { insertNotificationToSupabase } from './supabase/notifications'
|
||||
import { getProfile } from './love/supabase'
|
||||
|
||||
export const createLoveLikeNotification = async (like: Row<'love_likes'>) => {
|
||||
export const createProfileLikeNotification = async (like: Row<'profile_likes'>) => {
|
||||
const { creator_id, target_id, like_id } = like
|
||||
|
||||
const targetPrivateUser = await getPrivateUser(target_id)
|
||||
@@ -16,7 +16,7 @@ export const createLoveLikeNotification = async (like: Row<'love_likes'>) => {
|
||||
|
||||
const { sendToBrowser } = getNotificationDestinationsForUser(
|
||||
targetPrivateUser,
|
||||
'new_love_like'
|
||||
'new_profile_like'
|
||||
)
|
||||
if (!sendToBrowser) return
|
||||
|
||||
@@ -24,11 +24,11 @@ export const createLoveLikeNotification = async (like: Row<'love_likes'>) => {
|
||||
const notification: Notification = {
|
||||
id,
|
||||
userId: target_id,
|
||||
reason: 'new_love_like',
|
||||
reason: 'new_profile_like',
|
||||
createdTime: Date.now(),
|
||||
isSeen: false,
|
||||
sourceId: like_id,
|
||||
sourceType: 'love_like',
|
||||
sourceType: 'profile_like',
|
||||
sourceUpdateType: 'created',
|
||||
sourceUserName: profile.user.name,
|
||||
sourceUserUsername: profile.user.username,
|
||||
|
||||
@@ -11,7 +11,7 @@ BEGIN;
|
||||
\i backend/supabase/prompt_answers.sql
|
||||
\i backend/supabase/profile_comments.sql
|
||||
\i backend/supabase/compatibility_answers.sql
|
||||
\i backend/supabase/love_likes.sql
|
||||
\i backend/supabase/profile_likes.sql
|
||||
\i backend/supabase/love_questions.sql
|
||||
\i backend/supabase/love_ships.sql
|
||||
\i backend/supabase/love_stars.sql
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
CREATE TABLE IF NOT EXISTS love_likes (
|
||||
CREATE TABLE IF NOT EXISTS profile_likes (
|
||||
created_time TIMESTAMPTZ DEFAULT now() NOT NULL,
|
||||
creator_id TEXT NOT NULL,
|
||||
like_id TEXT DEFAULT random_alphanumeric(12) NOT NULL,
|
||||
target_id TEXT NOT NULL,
|
||||
CONSTRAINT love_likes_pkey PRIMARY KEY (creator_id, like_id)
|
||||
CONSTRAINT profile_likes_pkey PRIMARY KEY (creator_id, like_id)
|
||||
);
|
||||
|
||||
-- Row Level Security
|
||||
ALTER TABLE love_likes ENABLE ROW LEVEL SECURITY;
|
||||
ALTER TABLE profile_likes ENABLE ROW LEVEL SECURITY;
|
||||
|
||||
-- Policies
|
||||
DROP POLICY IF EXISTS "public read" ON love_likes;
|
||||
CREATE POLICY "public read" ON love_likes
|
||||
DROP POLICY IF EXISTS "public read" ON profile_likes;
|
||||
CREATE POLICY "public read" ON profile_likes
|
||||
FOR SELECT USING (true);
|
||||
|
||||
-- Indexes
|
||||
@@ -19,4 +19,4 @@ CREATE POLICY "public read" ON love_likes
|
||||
-- so we do not recreate that. Additional indexes:
|
||||
|
||||
CREATE INDEX IF NOT EXISTS user_likes_target_id_raw
|
||||
ON public.love_likes (target_id);
|
||||
ON public.profile_likes (target_id);
|
||||
@@ -32,7 +32,7 @@ export type Notification = {
|
||||
export const NOTIFICATION_TYPES_TO_SELECT = [
|
||||
'new_match', // new match markets
|
||||
'comment_on_profile', // endorsements
|
||||
'love_like',
|
||||
'profile_like',
|
||||
'love_ship',
|
||||
]
|
||||
|
||||
|
||||
@@ -136,7 +136,7 @@ export type Database = {
|
||||
}
|
||||
Relationships: []
|
||||
}
|
||||
love_likes: {
|
||||
profile_likes: {
|
||||
Row: {
|
||||
created_time: string
|
||||
creator_id: string
|
||||
|
||||
@@ -6,7 +6,7 @@ export type notification_preference = keyof notification_preferences
|
||||
export type notification_preferences = {
|
||||
new_match: notification_destination_types[]
|
||||
new_endorsement: notification_destination_types[]
|
||||
new_love_like: notification_destination_types[]
|
||||
new_profile_like: notification_destination_types[]
|
||||
new_love_ship: notification_destination_types[]
|
||||
new_search_alerts: notification_destination_types[]
|
||||
|
||||
@@ -40,7 +40,7 @@ export const getDefaultNotificationPreferences = (isDev?: boolean) => {
|
||||
new_match: constructPref(true, true, true),
|
||||
new_search_alerts: constructPref(true, true, true),
|
||||
new_endorsement: constructPref(true, true, true),
|
||||
new_love_like: constructPref(true, false, false),
|
||||
new_profile_like: constructPref(true, false, false),
|
||||
new_love_ship: constructPref(true, false, false),
|
||||
|
||||
// User-related
|
||||
|
||||
@@ -30,8 +30,8 @@ export function NotificationItem(props: { notification: Notification }) {
|
||||
return <CommentOnProfileNotification {...params} />
|
||||
} else if (sourceType === 'new_match') {
|
||||
return <NewMatchNotification {...params} />
|
||||
} else if (reason === 'new_love_like') {
|
||||
return <LoveLikeNotification {...params} />
|
||||
} else if (reason === 'new_profile_like') {
|
||||
return <ProfileLikeNotification {...params} />
|
||||
} else if (reason === 'new_love_ship') {
|
||||
return <LoveShipNotification {...params} />
|
||||
} else {
|
||||
@@ -119,7 +119,7 @@ export function NewMatchNotification(props: {
|
||||
)
|
||||
}
|
||||
|
||||
function LoveLikeNotification(props: {
|
||||
function ProfileLikeNotification(props: {
|
||||
notification: Notification
|
||||
highlighted: boolean
|
||||
setHighlighted: (highlighted: boolean) => void
|
||||
|
||||
@@ -53,8 +53,8 @@ function groupGeneralNotifications(
|
||||
new Date(n.createdTime).toDateString() +
|
||||
(n.sourceType === 'betting_streak_bonus' || n.reason === 'quest_payout'
|
||||
? 'quest_payout'
|
||||
: n.sourceType === 'love_like'
|
||||
? 'love_like'
|
||||
: n.sourceType === 'profile_like'
|
||||
? 'profile_like'
|
||||
: n.sourceType === 'love_ship'
|
||||
? 'love_ship'
|
||||
: n.data?.isPartner
|
||||
|
||||
@@ -160,7 +160,7 @@ const LoadedNotificationSettings = (props: { privateUser: PrivateUser }) => {
|
||||
question: '... sends you a new message?',
|
||||
},
|
||||
{
|
||||
type: 'new_love_like',
|
||||
type: 'new_profile_like',
|
||||
question: '... likes your profile?',
|
||||
},
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user