From 0311ee3e6ad51146e717495496684f5ef28fdb6c Mon Sep 17 00:00:00 2001 From: BryannYeap Date: Thu, 20 Oct 2022 20:02:19 +0800 Subject: [PATCH] [offers][chore] Add location to experience in the back end --- .../migrations/20221020115540_/migration.sql | 2 + apps/portal/prisma/schema.prisma | 49 ++++++++++--------- apps/portal/src/mappers/offers-mappers.ts | 1 + .../src/pages/offers/test/createProfile.tsx | 18 +++---- .../pages/offers/test/generateAnalysis.tsx | 2 +- .../router/offers/offers-profile-router.ts | 1 + apps/portal/src/types/offers.d.ts | 1 + 7 files changed, 40 insertions(+), 34 deletions(-) create mode 100644 apps/portal/prisma/migrations/20221020115540_/migration.sql diff --git a/apps/portal/prisma/migrations/20221020115540_/migration.sql b/apps/portal/prisma/migrations/20221020115540_/migration.sql new file mode 100644 index 00000000..a70f2aa5 --- /dev/null +++ b/apps/portal/prisma/migrations/20221020115540_/migration.sql @@ -0,0 +1,2 @@ +-- AlterTable +ALTER TABLE "OffersExperience" ADD COLUMN "location" TEXT; diff --git a/apps/portal/prisma/schema.prisma b/apps/portal/prisma/schema.prisma index 2857204b..48e068ca 100644 --- a/apps/portal/prisma/schema.prisma +++ b/apps/portal/prisma/schema.prisma @@ -91,17 +91,17 @@ enum TodoStatus { } model Company { - id String @id @default(cuid()) - name String @db.Text - slug String @unique - description String? @db.Text - logoUrl String? - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt + id String @id @default(cuid()) + name String @db.Text + slug String @unique + description String? @db.Text + logoUrl String? + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt - questionsQuestionEncounter QuestionsQuestionEncounter[] - OffersExperience OffersExperience[] - OffersOffer OffersOffer[] + questionsQuestionEncounter QuestionsQuestionEncounter[] + OffersExperience OffersExperience[] + OffersOffer OffersOffer[] } // Start of Resumes project models. @@ -232,6 +232,7 @@ model OffersExperience { // Add more fields durationInMonths Int? specialization String? + location String? // FULLTIME fields level String? @@ -405,20 +406,20 @@ model QuestionsQuestion { } model QuestionsQuestionEncounter { - id String @id @default(cuid()) - questionId String - userId String? - // TODO: sync with models (location, role) - companyId String - location String @db.Text - role String @db.Text - seenAt DateTime - createdAt DateTime @default(now()) - updatedAt DateTime @updatedAt - - company Company? @relation(fields: [companyId], references: [id], onDelete: SetNull) - user User? @relation(fields: [userId], references: [id], onDelete: SetNull) - question QuestionsQuestion @relation(fields: [questionId], references: [id], onDelete: Cascade) + id String @id @default(cuid()) + questionId String + userId String? + // TODO: sync with models (location, role) + companyId String + location String @db.Text + role String @db.Text + seenAt DateTime + createdAt DateTime @default(now()) + updatedAt DateTime @updatedAt + + company Company? @relation(fields: [companyId], references: [id], onDelete: SetNull) + user User? @relation(fields: [userId], references: [id], onDelete: SetNull) + question QuestionsQuestion @relation(fields: [questionId], references: [id], onDelete: Cascade) } model QuestionsQuestionVote { diff --git a/apps/portal/src/mappers/offers-mappers.ts b/apps/portal/src/mappers/offers-mappers.ts index 82a7a915..3933ab61 100644 --- a/apps/portal/src/mappers/offers-mappers.ts +++ b/apps/portal/src/mappers/offers-mappers.ts @@ -267,6 +267,7 @@ export const experienceDtoMapper = ( id: experience.id, jobType: experience.jobType, level: experience.level, + location: experience.location, monthlySalary: experience.monthlySalary ? valuationDtoMapper(experience.monthlySalary) : experience.monthlySalary, diff --git a/apps/portal/src/pages/offers/test/createProfile.tsx b/apps/portal/src/pages/offers/test/createProfile.tsx index 128960ff..ad891ce1 100644 --- a/apps/portal/src/pages/offers/test/createProfile.tsx +++ b/apps/portal/src/pages/offers/test/createProfile.tsx @@ -103,7 +103,7 @@ function Test() { ], experiences: [ { - companyId: 'cl9ec1mgg0000w33hg1a3612r', + companyId: 'cl9h0bqu50000txxwkhmshhxz', durationInMonths: 24, jobType: 'FULLTIME', level: 'Junior', @@ -132,7 +132,7 @@ function Test() { { comments: 'I am a Raffles Institution almumni', // Comments: '', - companyId: 'cl98yuqk80007txhgjtjp8fk4', + companyId: 'cl9h0bqu50000txxwkhmshhxz', jobType: 'FULLTIME', location: 'Singapore, Singapore', monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), @@ -161,7 +161,7 @@ function Test() { }, { comments: '', - companyId: 'cl98yuqk80007txhgjtjp8fk4', + companyId: 'cl9h0bqu50000txxwkhmshhxz', jobType: 'FULLTIME', location: 'Singapore, Singapore', monthYearReceived: new Date('2022-09-30T07:58:54.000Z'), @@ -263,7 +263,7 @@ function Test() { slug: 'meta', updatedAt: new Date('2022-10-12T16:19:05.196Z'), }, - companyId: 'cl9ec1mgg0000w33hg1a3612r', + companyId: 'cl9h0bqu50000txxwkhmshhxz', durationInMonths: 24, id: 'cl96stky6002iw32gpt6t87s2', jobType: 'FULLTIME', @@ -339,7 +339,7 @@ function Test() { slug: 'meta', updatedAt: new Date('2022-10-12T16:19:05.196Z'), }, - companyId: 'cl9ec1mgg0000w33hg1a3612r', + companyId: 'cl9h0bqu50000txxwkhmshhxz', id: 'cl976t4de00047iygl0zbce11', jobType: 'FULLTIME', location: 'Singapore, Singapore', @@ -392,7 +392,7 @@ function Test() { slug: 'meta', updatedAt: new Date('2022-10-12T16:19:05.196Z'), }, - companyId: 'cl9ec1mgg0000w33hg1a3612r', + companyId: 'cl9h0bqu50000txxwkhmshhxz', id: 'cl96stky80031w32gau9mu1gs', jobType: 'FULLTIME', location: 'Singapore, Singapore', @@ -445,7 +445,7 @@ function Test() { slug: 'meta', updatedAt: new Date('2022-10-12T16:19:05.196Z'), }, - companyId: 'cl9ec1mgg0000w33hg1a3612r', + companyId: 'cl9h0bqu50000txxwkhmshhxz', id: 'cl96stky9003bw32gc3l955vr', jobType: 'FULLTIME', location: 'Singapore, Singapore', @@ -498,7 +498,7 @@ function Test() { slug: 'meta', updatedAt: new Date('2022-10-12T16:19:05.196Z'), }, - companyId: 'cl9ec1mgg0000w33hg1a3612r', + companyId: 'cl9h0bqu50000txxwkhmshhxz', id: 'cl976wf28000t7iyga4noyz7s', jobType: 'FULLTIME', location: 'Singapore, Singapore', @@ -551,7 +551,7 @@ function Test() { slug: 'meta', updatedAt: new Date('2022-10-12T16:19:05.196Z'), }, - companyId: 'cl9ec1mgg0000w33hg1a3612r', + companyId: 'cl9h0bqu50000txxwkhmshhxz', id: 'cl96tbb3o0051w32gjrpaiiit', jobType: 'FULLTIME', location: 'Singapore, Singapore', diff --git a/apps/portal/src/pages/offers/test/generateAnalysis.tsx b/apps/portal/src/pages/offers/test/generateAnalysis.tsx index 5172175b..8fe0d84f 100644 --- a/apps/portal/src/pages/offers/test/generateAnalysis.tsx +++ b/apps/portal/src/pages/offers/test/generateAnalysis.tsx @@ -8,7 +8,7 @@ function GenerateAnalysis() { return (
{JSON.stringify( - analysisMutation.mutate({ profileId: 'cl98ywtbv0000tx1s4p18eol1' }), + analysisMutation.mutate({ profileId: 'cl9gvjn8b004di96vd1hhh9c4' }), )}
); diff --git a/apps/portal/src/server/router/offers/offers-profile-router.ts b/apps/portal/src/server/router/offers/offers-profile-router.ts index b17f3f3c..debf6096 100644 --- a/apps/portal/src/server/router/offers/offers-profile-router.ts +++ b/apps/portal/src/server/router/offers/offers-profile-router.ts @@ -75,6 +75,7 @@ const experience = z.object({ id: z.string().optional(), jobType: z.string().nullish(), level: z.string().nullish(), + location: z.string().nullish(), monthlySalary: valuation.nullish(), monthlySalaryId: z.string().nullish(), specialization: z.string().nullish(), diff --git a/apps/portal/src/types/offers.d.ts b/apps/portal/src/types/offers.d.ts index 35539b45..67f6392f 100644 --- a/apps/portal/src/types/offers.d.ts +++ b/apps/portal/src/types/offers.d.ts @@ -24,6 +24,7 @@ export type Experience = { id: string; jobType: JobType?; level: string?; + location: string?; monthlySalary: Valuation?; specialization: string?; title: string?;