Skip to content

Commit 015fe76

Browse files
committed
Hide profiles with small bio
1 parent 44666ae commit 015fe76

8 files changed

Lines changed: 75 additions & 58 deletions

File tree

backend/api/src/get-profiles.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import {createSupabaseDirectClient} from 'shared/supabase/init'
44
import {from, join, limit, orderBy, renderSql, select, where,} from 'shared/supabase/sql-builder'
55
import {getCompatibleProfiles} from 'api/compatible-profiles'
66
import {intersection} from 'lodash'
7-
import {MAX_INT, MIN_INT} from "common/constants";
7+
import {MAX_INT, MIN_BIO_LENGTH, MIN_INT} from "common/constants";
88

99
export type profileQueryType = {
1010
limit?: number | undefined,
@@ -81,7 +81,8 @@ export const loadProfiles = async (props: profileQueryType) => {
8181
(!is_smoker || l.is_smoker === is_smoker) &&
8282
(l.id.toString() != skipId) &&
8383
(!geodbCityIds ||
84-
(l.geodb_city_id && geodbCityIds.includes(l.geodb_city_id)))
84+
(l.geodb_city_id && geodbCityIds.includes(l.geodb_city_id))) &&
85+
((l.bio_length ?? 0) >= MIN_BIO_LENGTH)
8586
)
8687

8788
const cursor = after
@@ -153,6 +154,8 @@ export const loadProfiles = async (props: profileQueryType) => {
153154
{after}
154155
),
155156

157+
where(`bio_length >= ${MIN_BIO_LENGTH}`, {MIN_BIO_LENGTH}),
158+
156159
lastModificationWithin && where(`last_modification_time >= NOW() - INTERVAL $(lastModificationWithin)`, {lastModificationWithin}),
157160

158161
limitParam && limit(limitParam)

backend/email/emails/functions/mock.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { ProfileRow } from 'common/love/profile'
2-
import type { User } from 'common/user'
1+
import {ProfileRow} from 'common/love/profile'
2+
import type {User} from 'common/user'
33

44
// for email template testing
55

@@ -78,6 +78,7 @@ export const sinclairProfile: ProfileRow = {
7878
city_longitude: -122.416389,
7979
geodb_city_id: '126964',
8080
referred_by_username: null,
81+
bio_length: 1000,
8182
bio: {
8283
type: 'doc',
8384
content: [
@@ -173,6 +174,7 @@ export const jamesProfile: ProfileRow = {
173174
city_longitude: -122.416389,
174175
geodb_city_id: '126964',
175176
referred_by_username: null,
177+
bio_length: 1000,
176178
bio: {
177179
type: 'doc',
178180
content: [

backend/supabase/profiles.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ END$$;
99
CREATE TABLE IF NOT EXISTS profiles (
1010
age INTEGER NULL,
1111
bio JSONB,
12+
bio_length integer null,
1213
born_in_location TEXT,
1314
city TEXT NOT NULL,
1415
city_latitude NUMERIC(9, 6),
@@ -79,6 +80,10 @@ CREATE UNIQUE INDEX unique_user_id ON public.profiles USING btree (user_id);
7980
CREATE INDEX IF NOT EXISTS idx_profiles_last_mod_24h
8081
ON public.profiles USING btree (last_modification_time);
8182

83+
CREATE INDEX IF NOT EXISTS idx_profiles_bio_length
84+
ON profiles (bio_length);
85+
86+
8287
-- Functions and Triggers
8388
CREATE
8489
OR REPLACE FUNCTION update_last_modification_time()

common/src/api/zod-types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ export const baseProfilesSchema = z.object({
6262
visibility: z.union([z.literal('public'), z.literal('member')]),
6363

6464
bio: contentSchema.optional().nullable(),
65+
bio_length: z.number().optional().nullable(),
6566

6667
geodb_city_id: z.string().optional(),
6768
city: z.string(),

common/src/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ export const pStyle = "mt-1 text-gray-800 dark:text-white whitespace-pre-line";
1919

2020
export const IS_MAINTENANCE = false; // set to true to enable maintenance mode banner
2121

22-
export const MIN_BIO_LENGTH = 300;
22+
export const MIN_BIO_LENGTH = 250;

common/src/envs/dev.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ export const DEV_CONFIG: EnvConfig = {
55
domain: 'dev.compassmeet.com',
66
backendDomain: 'api.dev.compassmeet.com',
77
supabaseInstanceId: 'zbspxezubpzxmuxciurg',
8-
supabasePwd: 'FO3y0G7chzdq6aE7', // For database write access (dev). A 16-character password with digits and letters.
8+
supabasePwd: 'ZTNlifGKofSKhu8c', // For database write access (dev). A 16-character password with digits and letters.
99
supabaseAnonKey: 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Inpic3B4ZXp1YnB6eG11eGNpdXJnIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NTc2ODM0MTMsImV4cCI6MjA3MzI1OTQxM30.ZkM7zlawP8Nke0T3KJrqpOQ4DzqPaXTaJXLC2WU8Y7c',
1010
googleApplicationCredentials: 'googleApplicationCredentials-dev.json',
1111
firebaseConfig: {

common/src/supabase/schema.ts

Lines changed: 51 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -221,45 +221,6 @@ export type Database = {
221221
}
222222
Relationships: []
223223
}
224-
profile_comments: {
225-
Row: {
226-
content: Json
227-
created_time: string
228-
hidden: boolean
229-
id: number
230-
on_user_id: string
231-
reply_to_comment_id: number | null
232-
user_avatar_url: string
233-
user_id: string
234-
user_name: string
235-
user_username: string
236-
}
237-
Insert: {
238-
content: Json
239-
created_time?: string
240-
hidden?: boolean
241-
id?: never
242-
on_user_id: string
243-
reply_to_comment_id?: number | null
244-
user_avatar_url: string
245-
user_id: string
246-
user_name: string
247-
user_username: string
248-
}
249-
Update: {
250-
content?: Json
251-
created_time?: string
252-
hidden?: boolean
253-
id?: never
254-
on_user_id?: string
255-
reply_to_comment_id?: number | null
256-
user_avatar_url?: string
257-
user_id?: string
258-
user_name?: string
259-
user_username?: string
260-
}
261-
Relationships: []
262-
}
263224
private_user_message_channel_members: {
264225
Row: {
265226
channel_id: number
@@ -401,10 +362,50 @@ export type Database = {
401362
}
402363
Relationships: []
403364
}
365+
profile_comments: {
366+
Row: {
367+
content: Json
368+
created_time: string
369+
hidden: boolean
370+
id: number
371+
on_user_id: string
372+
reply_to_comment_id: number | null
373+
user_avatar_url: string
374+
user_id: string
375+
user_name: string
376+
user_username: string
377+
}
378+
Insert: {
379+
content: Json
380+
created_time?: string
381+
hidden?: boolean
382+
id?: number
383+
on_user_id: string
384+
reply_to_comment_id?: number | null
385+
user_avatar_url: string
386+
user_id: string
387+
user_name: string
388+
user_username: string
389+
}
390+
Update: {
391+
content?: Json
392+
created_time?: string
393+
hidden?: boolean
394+
id?: number
395+
on_user_id?: string
396+
reply_to_comment_id?: number | null
397+
user_avatar_url?: string
398+
user_id?: string
399+
user_name?: string
400+
user_username?: string
401+
}
402+
Relationships: []
403+
}
404404
profiles: {
405405
Row: {
406406
age: number | null
407407
bio: Json | null
408+
bio_length: number | null
408409
born_in_location: string | null
409410
city: string
410411
city_latitude: number | null
@@ -443,13 +444,14 @@ export type Database = {
443444
twitter: string | null
444445
university: string | null
445446
user_id: string
446-
visibility: Database['public']['Enums']['profile_visibility']
447+
visibility: Database['public']['Enums']['lover_visibility']
447448
wants_kids_strength: number
448449
website: string | null
449450
}
450451
Insert: {
451452
age?: number | null
452453
bio?: Json | null
454+
bio_length?: number | null
453455
born_in_location?: string | null
454456
city: string
455457
city_latitude?: number | null
@@ -488,13 +490,14 @@ export type Database = {
488490
twitter?: string | null
489491
university?: string | null
490492
user_id: string
491-
visibility?: Database['public']['Enums']['profile_visibility']
493+
visibility?: Database['public']['Enums']['lover_visibility']
492494
wants_kids_strength?: number
493495
website?: string | null
494496
}
495497
Update: {
496498
age?: number | null
497499
bio?: Json | null
500+
bio_length?: number | null
498501
born_in_location?: string | null
499502
city?: string
500503
city_latitude?: number | null
@@ -533,7 +536,7 @@ export type Database = {
533536
twitter?: string | null
534537
university?: string | null
535538
user_id?: string
536-
visibility?: Database['public']['Enums']['profile_visibility']
539+
visibility?: Database['public']['Enums']['lover_visibility']
537540
wants_kids_strength?: number
538541
website?: string | null
539542
}
@@ -693,6 +696,10 @@ export type Database = {
693696
Args: Record<PropertyKey, never>
694697
Returns: Record<string, unknown>[]
695698
}
699+
get_love_question_answers_and_lovers: {
700+
Args: { p_question_id: number }
701+
Returns: Record<string, unknown>[]
702+
}
696703
get_love_question_answers_and_profiles: {
697704
Args: { p_question_id: number }
698705
Returns: Record<string, unknown>[]
@@ -755,7 +762,7 @@ export type Database = {
755762
}
756763
}
757764
Enums: {
758-
profile_visibility: 'public' | 'member'
765+
lover_visibility: 'public' | 'member'
759766
}
760767
CompositeTypes: {
761768
[_ in never]: never
@@ -883,7 +890,7 @@ export type CompositeTypes<
883890
export const Constants = {
884891
public: {
885892
Enums: {
886-
profile_visibility: ['public', 'member'],
893+
lover_visibility: ['public', 'member'],
887894
},
888895
},
889896
} as const

web/components/bio/editable-bio.tsx

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {JSONContent} from '@tiptap/core'
1+
import {Editor} from '@tiptap/core'
22
import {MAX_DESCRIPTION_LENGTH} from 'common/envs/constants'
33
import {Profile} from 'common/love/profile'
44
import {tryCatch} from 'common/util/try-catch'
@@ -67,7 +67,8 @@ export function EditableBio(props: {
6767

6868
const saveBio = async () => {
6969
if (!editor) return
70-
const {error} = await tryCatch(updateProfile({bio: editor.getJSON()}))
70+
console.log(editor.getText().length)
71+
const {error} = await tryCatch(updateProfile({bio: editor.getJSON(), bio_length: editor.getText().length}))
7172

7273
if (error) {
7374
console.error(error)
@@ -111,16 +112,15 @@ export function EditableBio(props: {
111112
}
112113

113114
export function SignupBio(props: {
114-
onChange: (e: JSONContent) => void
115+
onChange: (e: Editor) => void
115116
}) {
116117
const {onChange} = props
117118
return (
118119
<Col className="relative w-full">
119120
<BaseBio
120121
onBlur={(editor) => {
121122
if (!editor) return
122-
const e = editor.getJSON()
123-
onChange(e)
123+
onChange(editor)
124124
}}
125125
/>
126126
</Col>
@@ -150,9 +150,8 @@ export function BaseBio({defaultValue, onBlur, onEditor}: BaseBioProps) {
150150
<div>
151151
{textLength < MIN_BIO_LENGTH &&
152152
<p>
153-
Write {MIN_BIO_LENGTH - textLength} more {MIN_BIO_LENGTH - textLength === 1 ? 'character' : 'characters'} so
154-
others can find you through keyword
155-
search and connect intentionally.
153+
Add {MIN_BIO_LENGTH - textLength} more {MIN_BIO_LENGTH - textLength === 1 ? 'character' : 'characters'} so
154+
your profile can appear in search results—or leave it for now and explore others’ profiles first.
156155
</p>
157156
}
158157
<BioTips/>

0 commit comments

Comments
 (0)