Skip to content

Commit b6d7955

Browse files
committed
Add profile field: place they grew up
1 parent 0277cc3 commit b6d7955

25 files changed

Lines changed: 404 additions & 212 deletions

backend/api/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@compass/api",
33
"description": "Backend API endpoints",
4-
"version": "1.10.1",
4+
"version": "1.11.0",
55
"private": true,
66
"scripts": {
77
"watch:serve": "tsx watch src/serve.ts",

backend/api/src/get-profiles.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ export type profileQueryType = {
5252
lat?: number | undefined
5353
lon?: number | undefined
5454
radius?: number | undefined
55+
raised_in_lat?: number | undefined
56+
raised_in_lon?: number | undefined
57+
raised_in_radius?: number | undefined
5558
compatibleWithUserId?: string | undefined
5659
skipId?: string | undefined
5760
orderBy?: string | undefined
@@ -107,6 +110,9 @@ export const loadProfiles = async (props: profileQueryType) => {
107110
lat,
108111
lon,
109112
radius,
113+
raised_in_lat,
114+
raised_in_lon,
115+
raised_in_radius,
110116
compatibleWithUserId,
111117
orderBy: orderByParam = 'created_time',
112118
lastModificationWithin,
@@ -115,6 +121,7 @@ export const loadProfiles = async (props: profileQueryType) => {
115121
} = props
116122

117123
const filterLocation = lat && lon && radius
124+
const filterRaisedInLocation = raised_in_lat && raised_in_lon && raised_in_radius
118125

119126
const keywords = name
120127
? name
@@ -372,6 +379,21 @@ export const loadProfiles = async (props: profileQueryType) => {
372379
{target_lat: lat, target_lon: lon, radius},
373380
),
374381

382+
filterRaisedInLocation &&
383+
where(
384+
`
385+
raised_in_lat BETWEEN $(target_lat) - ($(radius) / 69.0)
386+
AND $(target_lat) + ($(radius) / 69.0)
387+
AND raised_in_lon BETWEEN $(target_lon) - ($(radius) / (69.0 * COS(RADIANS($(target_lat)))))
388+
AND $(target_lon) + ($(radius) / (69.0 * COS(RADIANS($(target_lat)))))
389+
AND SQRT(
390+
POWER(raised_in_lat - $(target_lat), 2)
391+
+ POWER((raised_in_lon - $(target_lon)) * COS(RADIANS($(target_lat))), 2)
392+
) <= $(radius) / 69.0
393+
`,
394+
{target_lat: raised_in_lat, target_lon: raised_in_lon, radius: raised_in_radius},
395+
),
396+
375397
skipId && where(`profiles.user_id != $(skipId)`, {skipId}),
376398

377399
!shortBio &&

backend/email/emails/functions/mock.ts

Lines changed: 21 additions & 169 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,13 @@ import type {User} from 'common/user'
33

44
// for email template testing
55

6+
// A subset of Profile with only essential fields for testing
7+
export type PartialProfile = Pick<ProfileRow,
8+
'id' | 'user_id' | 'created_time' | 'last_modification_time' |
9+
'disabled' | 'looking_for_matches' | 'messaging_status' |
10+
'comments_enabled' | 'visibility'
11+
> & Partial<ProfileRow>
12+
613
export const mockUser: User = {
714
createdTime: 0,
815
bio: 'the futa in futarchy',
@@ -26,98 +33,22 @@ export const mockUser: User = {
2633
},
2734
}
2835

29-
export const sinclairProfile: ProfileRow = {
36+
export const sinclairProfile: PartialProfile = {
37+
// Required fields
3038
id: 55,
3139
user_id: '0k1suGSJKVUnHbCPEhHNpgZPkUP2',
3240
created_time: '2023-10-27T00:41:59.851776+00:00',
3341
last_modification_time: '2024-05-17T02:11:48.83+00:00',
34-
city: 'San Francisco',
35-
gender: 'trans-female',
36-
pref_gender: ['female', 'trans-female'],
37-
pref_age_min: 18,
38-
pref_age_max: 21,
39-
religion: [],
40-
image_descriptions: {},
41-
languages: ['english'],
42-
pref_relation_styles: ['friendship'],
43-
pref_romantic_styles: ['poly', 'open', 'mono'],
4442
disabled: false,
45-
wants_kids_strength: 3,
4643
looking_for_matches: true,
47-
visibility: 'public',
48-
mbti: 'intj',
4944
messaging_status: 'open',
5045
comments_enabled: true,
51-
has_kids: 0,
52-
is_smoker: false,
53-
drinks_per_month: 0,
54-
diet: null,
55-
political_beliefs: ['e/acc', 'libertarian'],
56-
relationship_status: ['married'],
57-
religious_belief_strength: null,
58-
religious_beliefs: null,
59-
political_details: '',
60-
photo_urls: [
61-
'https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FSinclair%2Flove-images%2FnJz22lr3Bl.jpg?alt=media&token=f1e99ba3-39cc-4637-8702-16a3a8dd49db',
62-
'https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FSinclair%2Flove-images%2FygM0mGgP_j.HEIC?alt=media&token=573b23d9-693c-4d6e-919b-097309f370e1',
63-
'https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FSinclair%2Flove-images%2FWPZNKxjHGV.HEIC?alt=media&token=190625e1-2cf0-49a6-824b-09b6f4002f2a',
64-
'https://firebasestorage.googleapis.com/v0/b/polylove.firebasestorage.app/o/user-images%2FSinclair%2Flove-images%2FlVFKKoLHyV.jpg?alt=media&token=ecb3a003-3672-4382-9ba0-ca894247bb3f',
65-
'https://firebasestorage.googleapis.com/v0/b/polylove.firebasestorage.app/o/user-images%2FSinclair%2Flove-images%2Fh659K0bmd4.jpg?alt=media&token=6561ed05-0e2d-4f31-95ee-c7c1c0b33ea6',
66-
'https://firebasestorage.googleapis.com/v0/b/polylove.firebasestorage.app/o/user-images%2FSinclair%2Flove-images%2F5OMTo5rhB-.jpg?alt=media&token=4aba4e5a-5115-4d2e-9d57-1e6162e15708',
67-
'https://firebasestorage.googleapis.com/v0/b/polylove.firebasestorage.app/o/user-images%2FSinclair%2Flove-images%2FwCT-Y-bgpc.jpg?alt=media&token=91994528-e436-4055-af69-421fa9e29e5c',
68-
],
69-
pinned_url:
70-
'https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FSinclair%2Flove-images%2FYXD19m12D7.jpg?alt=media&token=6cb095b4-dfc8-4bc9-ae67-6f12f29be0a5',
71-
ethnicity: ['asian'],
72-
born_in_location: null,
73-
height_in_inches: 70,
74-
education_level: 'bachelors',
75-
university: 'Santa Clara University',
76-
occupation: null,
77-
occupation_title: 'Founding Engineer',
78-
company: 'Manifold Markets',
79-
website: 'sincl.ai',
80-
twitter: 'x.com/singularitttt',
81-
region_code: 'CA',
82-
country: 'United States of America',
83-
city_latitude: 37.7775,
84-
city_longitude: -122.416389,
85-
geodb_city_id: '126964',
86-
referred_by_username: null,
87-
bio_length: 1000,
88-
bio: {
89-
type: 'doc',
90-
content: [
91-
{
92-
type: 'paragraph',
93-
content: [
94-
{
95-
type: 'text',
96-
marks: [
97-
{
98-
type: 'link',
99-
attrs: {
100-
href: 'https://sinclaaair.notion.site/Date-Me-487ef432c1f54938bf5e7a45ef05d57b',
101-
target: '_blank',
102-
},
103-
},
104-
],
105-
text: 'https://sinclaaair.notion.site/Date-Me-487ef432c1f54938bf5e7a45ef05d57b',
106-
},
107-
],
108-
},
109-
],
110-
},
111-
bio_text: 'the futa in futarchy',
112-
bio_tsv: 'the futa in futarchy',
113-
search_text: 'the futa in futarchy',
114-
search_tsv: 'the futa in futarchy',
46+
visibility: 'public',
47+
48+
// Optional commonly used fields for testing
49+
city: 'San Francisco',
50+
gender: 'trans-female',
11551
age: 25,
116-
big5_agreeableness: 10,
117-
big5_openness: 10,
118-
big5_conscientiousness: 10,
119-
big5_extraversion: 10,
120-
big5_neuroticism: 10,
12152
}
12253

12354
export const jamesUser: User = {
@@ -141,99 +72,20 @@ export const jamesUser: User = {
14172
},
14273
}
14374

144-
export const jamesProfile: ProfileRow = {
75+
export const jamesProfile: PartialProfile = {
76+
// Required fields
14577
id: 2,
14678
user_id: '5LZ4LgYuySdL1huCWe7bti02ghx2',
14779
created_time: '2023-10-21T21:18:26.691211+00:00',
14880
last_modification_time: '2024-05-17T02:11:48.83+00:00',
149-
city: 'San Francisco',
150-
gender: 'male',
151-
pref_gender: ['female'],
15281
disabled: false,
153-
pref_age_min: 22,
154-
pref_age_max: 32,
155-
religion: [],
156-
image_descriptions: {},
157-
languages: ['english'],
158-
pref_relation_styles: ['friendship'],
159-
pref_romantic_styles: ['poly', 'open', 'mono'],
160-
wants_kids_strength: 4,
16182
looking_for_matches: true,
162-
visibility: 'public',
16383
messaging_status: 'open',
16484
comments_enabled: true,
165-
has_kids: 0,
166-
is_smoker: false,
167-
drinks_per_month: 5,
168-
diet: null,
169-
political_beliefs: ['libertarian'],
170-
relationship_status: ['single'],
171-
religious_belief_strength: null,
172-
religious_beliefs: '',
173-
mbti: 'intj',
174-
political_details: '',
175-
photo_urls: [
176-
'https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FJamesGrugett%2Flove-images%2FKl0WtbZsZW.jpg?alt=media&token=c928604f-e5ff-4406-a229-152864a4aa48',
177-
'https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FJamesGrugett%2Flove-images%2Fsii17zOItz.jpg?alt=media&token=474034b9-0d23-4005-97ad-5864abfd85fe',
178-
'https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FJamesGrugett%2Flove-images%2F3ICeb-0mwB.jpg?alt=media&token=975dbdb9-5547-4553-b504-e6545eb82ec0',
179-
'https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FJamesGrugett%2Flove-images%2FdtuSGk_13Q.jpg?alt=media&token=98191d86-9d10-4571-879c-d00ab9cab09e',
180-
],
181-
pinned_url:
182-
'https://firebasestorage.googleapis.com/v0/b/mantic-markets.appspot.com/o/user-images%2FJamesGrugett%2Flove-images%2FXkLhuxZoOX.jpg?alt=media&token=7f2304dd-bace-4806-8e3c-78c35e57287c',
183-
ethnicity: ['caucasian'],
184-
born_in_location: 'Melbourne, FL',
185-
height_in_inches: 70,
186-
education_level: 'bachelors',
187-
university: 'Carnegie Mellon',
188-
occupation: 'Entrepreneur',
189-
occupation_title: 'CEO',
190-
company: 'Codebuff',
191-
website: 'https://jamesgrugett.com/',
192-
twitter: 'https://twitter.com/jahooma',
193-
region_code: 'CA',
194-
country: 'United States of America',
195-
city_latitude: 37.7775,
196-
city_longitude: -122.416389,
197-
geodb_city_id: '126964',
198-
referred_by_username: null,
199-
bio_length: 1000,
200-
bio: {
201-
type: 'doc',
202-
content: [
203-
{
204-
type: 'paragraph',
205-
content: [
206-
{
207-
type: 'text',
208-
text: "Optimist that's working to improve the world!",
209-
},
210-
],
211-
},
212-
{
213-
type: 'paragraph',
214-
},
215-
{
216-
type: 'paragraph',
217-
content: [
218-
{
219-
type: 'text',
220-
text: 'I like outdoor activities, hanging out with my housemates, strategy board games, libertarian and utilitarian ideas, getting boba, and riding my electric unicycle. I also enjoy working hard on bold new initiatives with huge potential for value creation!',
221-
},
222-
],
223-
},
224-
{
225-
type: 'paragraph',
226-
},
227-
],
228-
},
229-
bio_text: 'the futa in futarchy',
230-
bio_tsv: 'the futa in futarchy',
231-
search_text: 'the futa in futarchy',
232-
search_tsv: 'the futa in futarchy',
85+
visibility: 'public',
86+
87+
// Optional commonly used fields for testing
88+
city: 'San Francisco',
89+
gender: 'male',
23390
age: 32,
234-
big5_agreeableness: 10,
235-
big5_openness: 10,
236-
big5_conscientiousness: 10,
237-
big5_extraversion: 10,
238-
big5_neuroticism: 10,
23991
}

backend/supabase/migration.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,5 @@ BEGIN;
4747
\i backend/supabase/migrations/20251112_add_mbti_to_profiles.sql
4848
\i backend/supabase/migrations/20260213_add_big_5_to_profiles.sql
4949
\i backend/supabase/migrations/20260218_add_events.sql
50+
\i backend/supabase/migrations/20260218_add_notification_templates.sql
5051
COMMIT;

backend/supabase/profiles.sql

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ CREATE TABLE IF NOT EXISTS profiles (
4343
pref_gender TEXT[],
4444
pref_relation_styles TEXT[],
4545
pref_romantic_styles TEXT[],
46+
raised_in_city TEXT,
47+
raised_in_country TEXT,
48+
raised_in_geodb_city_id TEXT,
49+
raised_in_lat NUMERIC(9, 6),
50+
raised_in_lon NUMERIC(9, 6),
51+
raised_in_radius INTEGER,
52+
raised_in_region_code TEXT,
4653
referred_by_username TEXT,
4754
region_code TEXT,
4855
relationship_status TEXT[],
@@ -92,9 +99,11 @@ CREATE INDEX IF NOT EXISTS idx_profiles_bio_length
9299

93100
-- Fastest general-purpose index
94101
CREATE INDEX IF NOT EXISTS profiles_lat_lon_idx ON profiles (city_latitude, city_longitude);
102+
CREATE INDEX IF NOT EXISTS profiles_lat_lon_idx ON profiles (raised_in_lat, raised_in_lon);
95103

96104
-- Optional additional index for large tables / clustered inserts
97105
CREATE INDEX IF NOT EXISTS profiles_lat_lon_brin_idx ON profiles USING BRIN (city_latitude, city_longitude) WITH (pages_per_range = 32);
106+
CREATE INDEX IF NOT EXISTS profiles_lat_lon_brin_idx ON profiles USING BRIN (raised_in_lat, raised_in_lon) WITH (pages_per_range = 32);
98107

99108
CREATE INDEX profiles_pref_gender_gin ON profiles USING GIN (pref_gender);
100109
CREATE INDEX profiles_pref_relation_styles_gin ON profiles USING GIN (pref_relation_styles);
@@ -118,6 +127,7 @@ CREATE INDEX profiles_smoker_idx ON profiles (is_smoker);
118127
CREATE INDEX profiles_education_level_idx ON profiles (education_level);
119128
CREATE INDEX profiles_gender_idx ON profiles (gender);
120129
CREATE INDEX profiles_geodb_city_idx ON profiles (geodb_city_id);
130+
CREATE INDEX profiles_raised_in_geodb_city_idx ON profiles (raised_in_geodb_city_id);
121131

122132
CREATE INDEX profiles_recent_active_idx
123133
ON profiles (last_modification_time DESC)

common/src/api/schema.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -548,6 +548,9 @@ export const API = (_apiTypeCheck = {
548548
lat: z.coerce.number().optional(),
549549
lon: z.coerce.number().optional(),
550550
radius: z.coerce.number().optional(),
551+
raised_in_lat: z.coerce.number().optional(),
552+
raised_in_lon: z.coerce.number().optional(),
553+
raised_in_radius: z.coerce.number().optional(),
551554
compatibleWithUserId: z.string().optional(),
552555
skipId: z.string().optional(),
553556
locale: z.string().optional(),

common/src/api/zod-types.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,13 @@ const optionalProfilesSchema = z.object({
9797
political_beliefs: z.array(z.string()).optional().nullable(),
9898
political_details: z.string().optional().nullable(),
9999
pref_romantic_styles: z.array(z.string()).nullable(),
100+
raised_in_city: z.string().optional().nullable(),
101+
raised_in_country: z.string().optional().nullable(),
102+
raised_in_geodb_city_id: z.string().optional().nullable(),
103+
raised_in_lat: z.number().optional().nullable(),
104+
raised_in_lon: z.number().optional().nullable(),
105+
raised_in_radius: z.number().optional().nullable(),
106+
raised_in_region_code: z.string().optional().nullable(),
100107
relationship_status: z.array(z.string()).optional().nullable(),
101108
religion: z.array(z.string()).optional().nullable(),
102109
religious_belief_strength: z.number().optional().nullable(),

common/src/filters.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ export type FilterFields = {
1515
lat: number | null
1616
lon: number | null
1717
radius: number | null
18+
raised_in_lat: number | null
19+
raised_in_lon: number | null
20+
raised_in_radius: number | null
1821
genders: string[]
1922
education_levels: string[]
2023
mbti: string[]
@@ -73,6 +76,9 @@ export const initialFilters: Partial<FilterFields> = {
7376
lat: undefined,
7477
lon: undefined,
7578
radius: undefined,
79+
raised_in_lat: undefined,
80+
raised_in_lon: undefined,
81+
raised_in_radius: undefined,
7682
name: undefined,
7783
genders: undefined,
7884
education_levels: undefined,

0 commit comments

Comments
 (0)