From 58c4ec137788fd62eb5a4196861d106b8528c788 Mon Sep 17 00:00:00 2001 From: capJavert Date: Tue, 25 Nov 2025 14:13:21 +0100 Subject: [PATCH] feat: customLocation for user experience --- __tests__/common/profile/import.ts | 18 ++++++++++++++++++ src/common/profile/import.ts | 6 ++++-- src/entity/user/experiences/UserExperience.ts | 7 +++++++ ...4076115716-UserExperienceCustomLocation.ts | 19 +++++++++++++++++++ 4 files changed, 48 insertions(+), 2 deletions(-) create mode 100644 src/migration/1764076115716-UserExperienceCustomLocation.ts diff --git a/__tests__/common/profile/import.ts b/__tests__/common/profile/import.ts index 82e2eb64c..884a1e703 100644 --- a/__tests__/common/profile/import.ts +++ b/__tests__/common/profile/import.ts @@ -60,6 +60,10 @@ describe('UserExperienceType work import', () => { createdAt: expect.any(Date), updatedAt: expect.any(Date), flags: {}, + customLocation: { + city: 'New York', + country: 'USA', + }, }); const skills = await con .getRepository(UserExperienceSkill) @@ -98,6 +102,10 @@ describe('UserExperienceType work import', () => { userId: 'user-work-2', verified: false, flags: {}, + customLocation: { + city: 'Wahkkauppp', + country: 'Mars', + }, }); }); }); @@ -134,6 +142,9 @@ describe('UserExperienceType education import', () => { createdAt: expect.any(Date), updatedAt: expect.any(Date), flags: {}, + customLocation: { + country: 'Colombia', + }, }); }); @@ -167,6 +178,9 @@ describe('UserExperienceType education import', () => { createdAt: expect.any(Date), updatedAt: expect.any(Date), flags: {}, + customLocation: { + country: 'NowhereLand', + }, }); }); }); @@ -205,6 +219,7 @@ describe('UserExperienceType certification import', () => { createdAt: expect.any(Date), updatedAt: expect.any(Date), flags: {}, + customLocation: {}, }); }); @@ -241,6 +256,7 @@ describe('UserExperienceType certification import', () => { createdAt: expect.any(Date), updatedAt: expect.any(Date), flags: {}, + customLocation: {}, }); }); }); @@ -280,6 +296,7 @@ describe('UserExperienceType project import', () => { createdAt: expect.any(Date), updatedAt: expect.any(Date), flags: {}, + customLocation: {}, }); expect(skills.map((s) => s.value).sort()).toEqual( ['GraphQL', 'Node.js'].sort(), @@ -316,6 +333,7 @@ describe('UserExperienceType project import', () => { createdAt: expect.any(Date), updatedAt: expect.any(Date), flags: {}, + customLocation: {}, }); }); }); diff --git a/src/common/profile/import.ts b/src/common/profile/import.ts index 60086eb7b..426abb82c 100644 --- a/src/common/profile/import.ts +++ b/src/common/profile/import.ts @@ -66,7 +66,7 @@ const resolveUserLocationPart = async ({ } | null; con: EntityManager; threshold?: number; -}): Promise>> => { +}): Promise>> => { if (!location) { return {}; } @@ -125,7 +125,9 @@ const resolveUserLocationPart = async ({ }; } - return {}; + return { + customLocation: location, + }; }; export const importUserExperienceWork = async ({ diff --git a/src/entity/user/experiences/UserExperience.ts b/src/entity/user/experiences/UserExperience.ts index 8df32d5d6..34c56a7c1 100644 --- a/src/entity/user/experiences/UserExperience.ts +++ b/src/entity/user/experiences/UserExperience.ts @@ -69,6 +69,13 @@ export class UserExperience { @Column({ type: 'text', default: null }) locationId: string | null; + @Column({ type: 'jsonb', default: {} }) + customLocation: Partial<{ + city: string | null; + subdivision: string | null; + country: string | null; + }>; + @ManyToOne('DatasetLocation', { lazy: true, onDelete: 'SET NULL' }) @JoinColumn({ name: 'locationId', diff --git a/src/migration/1764076115716-UserExperienceCustomLocation.ts b/src/migration/1764076115716-UserExperienceCustomLocation.ts new file mode 100644 index 000000000..6c21809a5 --- /dev/null +++ b/src/migration/1764076115716-UserExperienceCustomLocation.ts @@ -0,0 +1,19 @@ +import { MigrationInterface, QueryRunner } from 'typeorm'; + +export class UserExperienceCustomLocation1764076115716 + implements MigrationInterface +{ + name = 'UserExperienceCustomLocation1764076115716'; + + public async up(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "user_experience" ADD "customLocation" jsonb NOT NULL DEFAULT '{}'`, + ); + } + + public async down(queryRunner: QueryRunner): Promise { + await queryRunner.query( + `ALTER TABLE "user_experience" DROP COLUMN "customLocation"`, + ); + } +}