Skip to content

Commit f1345d8

Browse files
committed
add indexes and update updateUserInfo endpoint to accept new prop
1 parent 38c5ceb commit f1345d8

7 files changed

Lines changed: 72 additions & 1 deletion

File tree

__tests__/boot.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ const LOGGED_IN_BODY = {
159159
clickbaitTries: null,
160160
hasLocationSet: false,
161161
location: null,
162+
hideExperience: false,
162163
},
163164
marketingCta: null,
164165
feeds: [],

__tests__/updateUserInfo.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ describe('mutation updateUserInfo', () => {
9696
country
9797
city
9898
}
99+
hideExperience
99100
}
100101
}
101102
`;
@@ -662,4 +663,53 @@ describe('mutation updateUserInfo', () => {
662663
expect(updatedUser?.readmeHtml).toContain('<h1>');
663664
// locationId check skipped - requires DatasetLocation records
664665
});
666+
667+
it('should update hideExperience', async () => {
668+
loggedUser = '1';
669+
const repo = con.getRepository(User);
670+
671+
// Verify initial state is false
672+
const user = await repo.findOneBy({ id: loggedUser });
673+
expect(user?.hideExperience).toBe(false);
674+
675+
const res = await client.mutate(MUTATION, {
676+
variables: {
677+
data: {
678+
hideExperience: true,
679+
username: 'testuser',
680+
name: 'Test User',
681+
},
682+
},
683+
});
684+
685+
expect(res.errors).toBeFalsy();
686+
expect(res.data.updateUserInfo.hideExperience).toBe(true);
687+
688+
const updatedUser = await repo.findOneBy({ id: loggedUser });
689+
expect(updatedUser?.hideExperience).toBe(true);
690+
});
691+
692+
it('should update hideExperience to false', async () => {
693+
loggedUser = '1';
694+
const repo = con.getRepository(User);
695+
696+
// Set hideExperience to true first
697+
await repo.update({ id: loggedUser }, { hideExperience: true });
698+
699+
const res = await client.mutate(MUTATION, {
700+
variables: {
701+
data: {
702+
hideExperience: false,
703+
username: 'testuser',
704+
name: 'Test User',
705+
},
706+
},
707+
});
708+
709+
expect(res.errors).toBeFalsy();
710+
expect(res.data.updateUserInfo.hideExperience).toBe(false);
711+
712+
const updatedUser = await repo.findOneBy({ id: loggedUser });
713+
expect(updatedUser?.hideExperience).toBe(false);
714+
});
665715
});

src/entity/user/User.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -345,6 +345,7 @@ export class User {
345345
@Column({ type: 'text', default: null })
346346
locationId: string | null;
347347

348+
@Index('IDX_user_hideExperience')
348349
@Column({ type: 'boolean', default: false })
349350
hideExperience: boolean;
350351

src/migration/1764520729009-UserHideExperience.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,19 @@
11
import { MigrationInterface, QueryRunner } from 'typeorm';
22

33
export class UserHideExperience1764520729009 implements MigrationInterface {
4+
name = 'UserHideExperience1764520729009';
5+
46
public async up(queryRunner: QueryRunner): Promise<void> {
57
await queryRunner.query(
68
`ALTER TABLE "user" ADD IF NOT EXISTS "hideExperience" boolean NOT NULL DEFAULT false`,
79
);
10+
await queryRunner.query(
11+
`CREATE INDEX IF NOT EXISTS "IDX_user_hideExperience" ON "user" ("hideExperience")`,
12+
);
813
}
914

1015
public async down(queryRunner: QueryRunner): Promise<void> {
16+
await queryRunner.query(`DROP INDEX IF EXISTS "IDX_user_hideExperience"`);
1117
await queryRunner.query(
1218
`ALTER TABLE "user" DROP COLUMN IF EXISTS "hideExperience"`,
1319
);

src/routes/boot.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -479,6 +479,7 @@ const getUser = (
479479
'locationId',
480480
'readme',
481481
'language',
482+
'hideExperience',
482483
],
483484
});
484485

src/schema/users.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ export interface GQLUpdateUserInfoInput extends GQLUpdateUserInput {
205205
externalLocationId?: string;
206206
cover?: string;
207207
readme?: string;
208+
hideExperience?: boolean;
208209
}
209210

210211
interface GQLUserParameters {
@@ -534,6 +535,10 @@ export const typeDefs = /* GraphQL */ `
534535
Where the user is located
535536
"""
536537
location: DatasetLocation
538+
"""
539+
Whether to hide user's experience
540+
"""
541+
hideExperience: Boolean
537542
}
538543
539544
"""
@@ -824,6 +829,10 @@ export const typeDefs = /* GraphQL */ `
824829
The user's readme
825830
"""
826831
readme: String
832+
"""
833+
Whether to hide user's experience
834+
"""
835+
hideExperience: Boolean
827836
}
828837
829838
type TagsReadingStatus {

src/workers/opportunity/parseCVProfile.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ export const parseCVProfileWorker: TypedNotificationWorker<'api.v1.candidate-pre
102102
if (existingExperiencesCount === 0) {
103103
await con
104104
.getRepository(User)
105-
.update({ id: userId }, { hideExperience: true });
105+
.update(
106+
{ id: userId, hideExperience: false },
107+
{ hideExperience: true },
108+
);
106109
}
107110

108111
return [

0 commit comments

Comments
 (0)