Skip to content

Commit 58c4ec1

Browse files
committed
feat: customLocation for user experience
1 parent a19b4c7 commit 58c4ec1

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

__tests__/common/profile/import.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@ describe('UserExperienceType work import', () => {
6060
createdAt: expect.any(Date),
6161
updatedAt: expect.any(Date),
6262
flags: {},
63+
customLocation: {
64+
city: 'New York',
65+
country: 'USA',
66+
},
6367
});
6468
const skills = await con
6569
.getRepository(UserExperienceSkill)
@@ -98,6 +102,10 @@ describe('UserExperienceType work import', () => {
98102
userId: 'user-work-2',
99103
verified: false,
100104
flags: {},
105+
customLocation: {
106+
city: 'Wahkkauppp',
107+
country: 'Mars',
108+
},
101109
});
102110
});
103111
});
@@ -134,6 +142,9 @@ describe('UserExperienceType education import', () => {
134142
createdAt: expect.any(Date),
135143
updatedAt: expect.any(Date),
136144
flags: {},
145+
customLocation: {
146+
country: 'Colombia',
147+
},
137148
});
138149
});
139150

@@ -167,6 +178,9 @@ describe('UserExperienceType education import', () => {
167178
createdAt: expect.any(Date),
168179
updatedAt: expect.any(Date),
169180
flags: {},
181+
customLocation: {
182+
country: 'NowhereLand',
183+
},
170184
});
171185
});
172186
});
@@ -205,6 +219,7 @@ describe('UserExperienceType certification import', () => {
205219
createdAt: expect.any(Date),
206220
updatedAt: expect.any(Date),
207221
flags: {},
222+
customLocation: {},
208223
});
209224
});
210225

@@ -241,6 +256,7 @@ describe('UserExperienceType certification import', () => {
241256
createdAt: expect.any(Date),
242257
updatedAt: expect.any(Date),
243258
flags: {},
259+
customLocation: {},
244260
});
245261
});
246262
});
@@ -280,6 +296,7 @@ describe('UserExperienceType project import', () => {
280296
createdAt: expect.any(Date),
281297
updatedAt: expect.any(Date),
282298
flags: {},
299+
customLocation: {},
283300
});
284301
expect(skills.map((s) => s.value).sort()).toEqual(
285302
['GraphQL', 'Node.js'].sort(),
@@ -316,6 +333,7 @@ describe('UserExperienceType project import', () => {
316333
createdAt: expect.any(Date),
317334
updatedAt: expect.any(Date),
318335
flags: {},
336+
customLocation: {},
319337
});
320338
});
321339
});

src/common/profile/import.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ const resolveUserLocationPart = async ({
6666
} | null;
6767
con: EntityManager;
6868
threshold?: number;
69-
}): Promise<Partial<Pick<UserExperience, 'locationId'>>> => {
69+
}): Promise<Partial<Pick<UserExperience, 'locationId' | 'customLocation'>>> => {
7070
if (!location) {
7171
return {};
7272
}
@@ -125,7 +125,9 @@ const resolveUserLocationPart = async ({
125125
};
126126
}
127127

128-
return {};
128+
return {
129+
customLocation: location,
130+
};
129131
};
130132

131133
export const importUserExperienceWork = async ({

src/entity/user/experiences/UserExperience.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,13 @@ export class UserExperience {
6969
@Column({ type: 'text', default: null })
7070
locationId: string | null;
7171

72+
@Column({ type: 'jsonb', default: {} })
73+
customLocation: Partial<{
74+
city: string | null;
75+
subdivision: string | null;
76+
country: string | null;
77+
}>;
78+
7279
@ManyToOne('DatasetLocation', { lazy: true, onDelete: 'SET NULL' })
7380
@JoinColumn({
7481
name: 'locationId',
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { MigrationInterface, QueryRunner } from 'typeorm';
2+
3+
export class UserExperienceCustomLocation1764076115716
4+
implements MigrationInterface
5+
{
6+
name = 'UserExperienceCustomLocation1764076115716';
7+
8+
public async up(queryRunner: QueryRunner): Promise<void> {
9+
await queryRunner.query(
10+
`ALTER TABLE "user_experience" ADD "customLocation" jsonb NOT NULL DEFAULT '{}'`,
11+
);
12+
}
13+
14+
public async down(queryRunner: QueryRunner): Promise<void> {
15+
await queryRunner.query(
16+
`ALTER TABLE "user_experience" DROP COLUMN "customLocation"`,
17+
);
18+
}
19+
}

0 commit comments

Comments
 (0)