[offers][chore] Change company field in AnalysisUnit

pull/496/head
Bryann Yeap Kok Keong 2 years ago
parent 7419cb4608
commit ca17ef9162

@ -0,0 +1,13 @@
/*
Warnings:
- You are about to drop the column `companyName` on the `OffersAnalysisUnit` table. All the data in the column will be lost.
- Added the required column `companyId` to the `OffersAnalysisUnit` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE "OffersAnalysisUnit" DROP COLUMN "companyName",
ADD COLUMN "companyId" TEXT NOT NULL;
-- AddForeignKey
ALTER TABLE "OffersAnalysisUnit" ADD CONSTRAINT "OffersAnalysisUnit_companyId_fkey" FOREIGN KEY ("companyId") REFERENCES "Company"("id") ON DELETE RESTRICT ON UPDATE CASCADE;

@ -104,6 +104,7 @@ model Company {
questionsQuestionEncounter QuestionsQuestionEncounter[] questionsQuestionEncounter QuestionsQuestionEncounter[]
OffersExperience OffersExperience[] OffersExperience OffersExperience[]
OffersOffer OffersOffer[] OffersOffer OffersOffer[]
OffersAnalysisUnit OffersAnalysisUnit[]
} }
model Country { model Country {
@ -418,7 +419,9 @@ model OffersAnalysis {
model OffersAnalysisUnit { model OffersAnalysisUnit {
id String @id @default(cuid()) id String @id @default(cuid())
companyName String company Company @relation(fields: [companyId], references: [id])
companyId String
percentile Float percentile Float
noOfSimilarOffers Int noOfSimilarOffers Int
topSimilarOffers OffersOffer[] topSimilarOffers OffersOffer[]

@ -126,6 +126,7 @@ const analysisOfferDtoMapper = (
const analysisUnitDtoMapper = ( const analysisUnitDtoMapper = (
analysisUnit: OffersAnalysisUnit & { analysisUnit: OffersAnalysisUnit & {
company: Company;
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;
@ -153,7 +154,7 @@ const analysisUnitDtoMapper = (
}, },
) => { ) => {
const analysisDto: AnalysisUnit = { const analysisDto: AnalysisUnit = {
companyName: analysisUnit.companyName, companyName: analysisUnit.company.name,
noOfOffers: analysisUnit.noOfSimilarOffers, noOfOffers: analysisUnit.noOfSimilarOffers,
percentile: analysisUnit.percentile, percentile: analysisUnit.percentile,
topPercentileOffers: analysisUnit.topSimilarOffers.map((offer) => topPercentileOffers: analysisUnit.topSimilarOffers.map((offer) =>
@ -189,6 +190,7 @@ export const profileAnalysisDtoMapper = (
| (OffersAnalysis & { | (OffersAnalysis & {
companyAnalysis: Array< companyAnalysis: Array<
OffersAnalysisUnit & { OffersAnalysisUnit & {
company: Company;
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;
@ -218,6 +220,7 @@ export const profileAnalysisDtoMapper = (
} }
>; >;
overallAnalysis: OffersAnalysisUnit & { overallAnalysis: OffersAnalysisUnit & {
company: Company;
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;
@ -501,6 +504,7 @@ export const profileDtoMapper = (
| (OffersAnalysis & { | (OffersAnalysis & {
companyAnalysis: Array< companyAnalysis: Array<
OffersAnalysisUnit & { OffersAnalysisUnit & {
company: Company;
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;
@ -532,6 +536,7 @@ export const profileDtoMapper = (
} }
>; >;
overallAnalysis: OffersAnalysisUnit & { overallAnalysis: OffersAnalysisUnit & {
company: Company;
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;

@ -16,6 +16,7 @@ export const offersAnalysisRouter = createRouter()
include: { include: {
companyAnalysis: { companyAnalysis: {
include: { include: {
company: true,
topSimilarOffers: { topSimilarOffers: {
include: { include: {
company: true, company: true,
@ -66,6 +67,7 @@ export const offersAnalysisRouter = createRouter()
}, },
overallAnalysis: { overallAnalysis: {
include: { include: {
company: true,
topSimilarOffers: { topSimilarOffers: {
include: { include: {
company: true, company: true,

@ -168,6 +168,7 @@ export const offersProfileRouter = createRouter()
include: { include: {
companyAnalysis: { companyAnalysis: {
include: { include: {
company: true,
topSimilarOffers: { topSimilarOffers: {
include: { include: {
company: true, company: true,
@ -218,6 +219,7 @@ export const offersProfileRouter = createRouter()
}, },
overallAnalysis: { overallAnalysis: {
include: { include: {
company: true,
topSimilarOffers: { topSimilarOffers: {
include: { include: {
company: true, company: true,
@ -425,8 +427,8 @@ export const offersProfileRouter = createRouter()
level: x.level, level: x.level,
location: { location: {
connect: { connect: {
id: x.cityId id: x.cityId,
} },
}, },
title: x.title, title: x.title,
totalCompensation: totalCompensation:
@ -481,9 +483,9 @@ export const offersProfileRouter = createRouter()
location: { location: {
connect: { connect: {
where: { where: {
id: x.cityId id: x.cityId,
} },
} },
}, },
title: x.title, title: x.title,
totalCompensation: totalCompensation:
@ -539,9 +541,9 @@ export const offersProfileRouter = createRouter()
location: { location: {
connect: { connect: {
where: { where: {
id: x.cityId id: x.cityId,
} },
} },
}, },
monthlySalary: monthlySalary:
x.monthlySalary != null x.monthlySalary != null
@ -595,9 +597,9 @@ export const offersProfileRouter = createRouter()
location: { location: {
connect: { connect: {
where: { where: {
id: x.cityId id: x.cityId,
} },
} },
}, },
monthlySalary: monthlySalary:
x.monthlySalary != null x.monthlySalary != null
@ -680,8 +682,8 @@ export const offersProfileRouter = createRouter()
jobType: x.jobType, jobType: x.jobType,
location: { location: {
connect: { connect: {
id: x.cityId id: x.cityId,
} },
}, },
monthYearReceived: x.monthYearReceived, monthYearReceived: x.monthYearReceived,
negotiationStrategy: x.negotiationStrategy, negotiationStrategy: x.negotiationStrategy,
@ -724,8 +726,8 @@ export const offersProfileRouter = createRouter()
jobType: x.jobType, jobType: x.jobType,
location: { location: {
connect: { connect: {
id: x.cityId id: x.cityId,
} },
}, },
monthYearReceived: x.monthYearReceived, monthYearReceived: x.monthYearReceived,
negotiationStrategy: x.negotiationStrategy, negotiationStrategy: x.negotiationStrategy,
@ -1074,8 +1076,8 @@ export const offersProfileRouter = createRouter()
level: exp.level, level: exp.level,
location: { location: {
connect: { connect: {
id: exp.cityId id: exp.cityId,
} },
}, },
title: exp.title, title: exp.title,
totalCompensation: exp.totalCompensation totalCompensation: exp.totalCompensation
@ -1145,8 +1147,8 @@ export const offersProfileRouter = createRouter()
level: exp.level, level: exp.level,
location: { location: {
connect: { connect: {
id: exp.cityId id: exp.cityId,
} },
}, },
title: exp.title, title: exp.title,
totalCompensation: { totalCompensation: {
@ -1213,8 +1215,8 @@ export const offersProfileRouter = createRouter()
level: exp.level, level: exp.level,
location: { location: {
connect: { connect: {
id: exp.cityId id: exp.cityId,
} },
}, },
title: exp.title, title: exp.title,
}, },
@ -1256,8 +1258,8 @@ export const offersProfileRouter = createRouter()
level: exp.level, level: exp.level,
location: { location: {
connect: { connect: {
id: exp.cityId id: exp.cityId,
} },
}, },
title: exp.title, title: exp.title,
}, },
@ -1305,8 +1307,8 @@ export const offersProfileRouter = createRouter()
jobType: exp.jobType, jobType: exp.jobType,
location: { location: {
connect: { connect: {
id: exp.cityId id: exp.cityId,
} },
}, },
monthlySalary: { monthlySalary: {
create: { create: {
@ -1370,8 +1372,8 @@ export const offersProfileRouter = createRouter()
jobType: exp.jobType, jobType: exp.jobType,
location: { location: {
connect: { connect: {
id: exp.cityId id: exp.cityId,
} },
}, },
monthlySalary: { monthlySalary: {
create: { create: {
@ -1437,7 +1439,7 @@ export const offersProfileRouter = createRouter()
location: { location: {
connect: { connect: {
id: exp.cityId, id: exp.cityId,
} },
}, },
title: exp.title, title: exp.title,
}, },
@ -1477,8 +1479,8 @@ export const offersProfileRouter = createRouter()
jobType: exp.jobType, jobType: exp.jobType,
location: { location: {
connect: { connect: {
id: exp.cityId id: exp.cityId,
} },
}, },
title: exp.title, title: exp.title,
}, },
@ -1584,8 +1586,8 @@ export const offersProfileRouter = createRouter()
comments: offerToUpdate.comments, comments: offerToUpdate.comments,
company: { company: {
connect: { connect: {
id: offerToUpdate.companyId id: offerToUpdate.companyId,
} },
}, },
jobType: jobType:
offerToUpdate.jobType === JobType.FULLTIME offerToUpdate.jobType === JobType.FULLTIME
@ -1593,8 +1595,8 @@ export const offersProfileRouter = createRouter()
: JobType.INTERN, : JobType.INTERN,
location: { location: {
connect: { connect: {
id: offerToUpdate.cityId id: offerToUpdate.cityId,
} },
}, },
monthYearReceived: offerToUpdate.monthYearReceived, monthYearReceived: offerToUpdate.monthYearReceived,
negotiationStrategy: offerToUpdate.negotiationStrategy, negotiationStrategy: offerToUpdate.negotiationStrategy,
@ -1820,8 +1822,8 @@ export const offersProfileRouter = createRouter()
jobType: offerToUpdate.jobType, jobType: offerToUpdate.jobType,
location: { location: {
connect: { connect: {
id: offerToUpdate.cityId id: offerToUpdate.cityId,
} },
}, },
monthYearReceived: offerToUpdate.monthYearReceived, monthYearReceived: offerToUpdate.monthYearReceived,
negotiationStrategy: offerToUpdate.negotiationStrategy, negotiationStrategy: offerToUpdate.negotiationStrategy,
@ -1878,8 +1880,8 @@ export const offersProfileRouter = createRouter()
jobType: offerToUpdate.jobType, jobType: offerToUpdate.jobType,
location: { location: {
connect: { connect: {
id: offerToUpdate.cityId id: offerToUpdate.cityId,
} },
}, },
monthYearReceived: offerToUpdate.monthYearReceived, monthYearReceived: offerToUpdate.monthYearReceived,
negotiationStrategy: offerToUpdate.negotiationStrategy, negotiationStrategy: offerToUpdate.negotiationStrategy,

@ -292,7 +292,7 @@ export const generateAnalysis = async (params: {
: similarCompanyOffers; : similarCompanyOffers;
return { return {
companyName: companyOffer.company.name, companyId: companyOffer.companyId,
noOfSimilarOffers: noOfSimilarCompanyOffers, noOfSimilarOffers: noOfSimilarCompanyOffers,
percentile: companyPercentile, percentile: companyPercentile,
topSimilarOffers: topPercentileCompanyOffers, topSimilarOffers: topPercentileCompanyOffers,
@ -329,7 +329,11 @@ export const generateAnalysis = async (params: {
companyAnalysis: { companyAnalysis: {
create: companyAnalysis.map((analysisUnit) => { create: companyAnalysis.map((analysisUnit) => {
return { return {
companyName: analysisUnit.companyName, company: {
connect: {
id: analysisUnit.companyId,
},
},
noOfSimilarOffers: analysisUnit.noOfSimilarOffers, noOfSimilarOffers: analysisUnit.noOfSimilarOffers,
percentile: analysisUnit.percentile, percentile: analysisUnit.percentile,
topSimilarOffers: { topSimilarOffers: {
@ -342,7 +346,11 @@ export const generateAnalysis = async (params: {
}, },
overallAnalysis: { overallAnalysis: {
create: { create: {
companyName: overallHighestOffer.company.name, company: {
connect: {
id: overallHighestOffer.companyId,
},
},
noOfSimilarOffers, noOfSimilarOffers,
percentile: overallPercentile, percentile: overallPercentile,
topSimilarOffers: { topSimilarOffers: {
@ -366,6 +374,7 @@ export const generateAnalysis = async (params: {
include: { include: {
companyAnalysis: { companyAnalysis: {
include: { include: {
company: true,
topSimilarOffers: { topSimilarOffers: {
include: { include: {
company: true, company: true,
@ -416,6 +425,7 @@ export const generateAnalysis = async (params: {
}, },
overallAnalysis: { overallAnalysis: {
include: { include: {
company: true,
topSimilarOffers: { topSimilarOffers: {
include: { include: {
company: true, company: true,

Loading…
Cancel
Save