mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-02-03 02:24:47 +08:00
[offers][chore] Change company field in AnalysisUnit
This commit is contained in:
@@ -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[]
|
||||
OffersExperience OffersExperience[]
|
||||
OffersOffer OffersOffer[]
|
||||
OffersAnalysisUnit OffersAnalysisUnit[]
|
||||
}
|
||||
|
||||
model Country {
|
||||
@@ -418,7 +419,9 @@ model OffersAnalysis {
|
||||
model OffersAnalysisUnit {
|
||||
id String @id @default(cuid())
|
||||
|
||||
companyName String
|
||||
company Company @relation(fields: [companyId], references: [id])
|
||||
companyId String
|
||||
|
||||
percentile Float
|
||||
noOfSimilarOffers Int
|
||||
topSimilarOffers OffersOffer[]
|
||||
|
||||
@@ -126,6 +126,7 @@ const analysisOfferDtoMapper = (
|
||||
|
||||
const analysisUnitDtoMapper = (
|
||||
analysisUnit: OffersAnalysisUnit & {
|
||||
company: Company;
|
||||
topSimilarOffers: Array<
|
||||
OffersOffer & {
|
||||
company: Company;
|
||||
@@ -153,7 +154,7 @@ const analysisUnitDtoMapper = (
|
||||
},
|
||||
) => {
|
||||
const analysisDto: AnalysisUnit = {
|
||||
companyName: analysisUnit.companyName,
|
||||
companyName: analysisUnit.company.name,
|
||||
noOfOffers: analysisUnit.noOfSimilarOffers,
|
||||
percentile: analysisUnit.percentile,
|
||||
topPercentileOffers: analysisUnit.topSimilarOffers.map((offer) =>
|
||||
@@ -189,6 +190,7 @@ export const profileAnalysisDtoMapper = (
|
||||
| (OffersAnalysis & {
|
||||
companyAnalysis: Array<
|
||||
OffersAnalysisUnit & {
|
||||
company: Company;
|
||||
topSimilarOffers: Array<
|
||||
OffersOffer & {
|
||||
company: Company;
|
||||
@@ -218,6 +220,7 @@ export const profileAnalysisDtoMapper = (
|
||||
}
|
||||
>;
|
||||
overallAnalysis: OffersAnalysisUnit & {
|
||||
company: Company;
|
||||
topSimilarOffers: Array<
|
||||
OffersOffer & {
|
||||
company: Company;
|
||||
@@ -501,6 +504,7 @@ export const profileDtoMapper = (
|
||||
| (OffersAnalysis & {
|
||||
companyAnalysis: Array<
|
||||
OffersAnalysisUnit & {
|
||||
company: Company;
|
||||
topSimilarOffers: Array<
|
||||
OffersOffer & {
|
||||
company: Company;
|
||||
@@ -532,6 +536,7 @@ export const profileDtoMapper = (
|
||||
}
|
||||
>;
|
||||
overallAnalysis: OffersAnalysisUnit & {
|
||||
company: Company;
|
||||
topSimilarOffers: Array<
|
||||
OffersOffer & {
|
||||
company: Company;
|
||||
|
||||
@@ -16,6 +16,7 @@ export const offersAnalysisRouter = createRouter()
|
||||
include: {
|
||||
companyAnalysis: {
|
||||
include: {
|
||||
company: true,
|
||||
topSimilarOffers: {
|
||||
include: {
|
||||
company: true,
|
||||
@@ -66,6 +67,7 @@ export const offersAnalysisRouter = createRouter()
|
||||
},
|
||||
overallAnalysis: {
|
||||
include: {
|
||||
company: true,
|
||||
topSimilarOffers: {
|
||||
include: {
|
||||
company: true,
|
||||
|
||||
@@ -168,6 +168,7 @@ export const offersProfileRouter = createRouter()
|
||||
include: {
|
||||
companyAnalysis: {
|
||||
include: {
|
||||
company: true,
|
||||
topSimilarOffers: {
|
||||
include: {
|
||||
company: true,
|
||||
@@ -218,6 +219,7 @@ export const offersProfileRouter = createRouter()
|
||||
},
|
||||
overallAnalysis: {
|
||||
include: {
|
||||
company: true,
|
||||
topSimilarOffers: {
|
||||
include: {
|
||||
company: true,
|
||||
@@ -425,8 +427,8 @@ export const offersProfileRouter = createRouter()
|
||||
level: x.level,
|
||||
location: {
|
||||
connect: {
|
||||
id: x.cityId
|
||||
}
|
||||
id: x.cityId,
|
||||
},
|
||||
},
|
||||
title: x.title,
|
||||
totalCompensation:
|
||||
@@ -481,9 +483,9 @@ export const offersProfileRouter = createRouter()
|
||||
location: {
|
||||
connect: {
|
||||
where: {
|
||||
id: x.cityId
|
||||
}
|
||||
}
|
||||
id: x.cityId,
|
||||
},
|
||||
},
|
||||
},
|
||||
title: x.title,
|
||||
totalCompensation:
|
||||
@@ -539,9 +541,9 @@ export const offersProfileRouter = createRouter()
|
||||
location: {
|
||||
connect: {
|
||||
where: {
|
||||
id: x.cityId
|
||||
}
|
||||
}
|
||||
id: x.cityId,
|
||||
},
|
||||
},
|
||||
},
|
||||
monthlySalary:
|
||||
x.monthlySalary != null
|
||||
@@ -595,9 +597,9 @@ export const offersProfileRouter = createRouter()
|
||||
location: {
|
||||
connect: {
|
||||
where: {
|
||||
id: x.cityId
|
||||
}
|
||||
}
|
||||
id: x.cityId,
|
||||
},
|
||||
},
|
||||
},
|
||||
monthlySalary:
|
||||
x.monthlySalary != null
|
||||
@@ -680,8 +682,8 @@ export const offersProfileRouter = createRouter()
|
||||
jobType: x.jobType,
|
||||
location: {
|
||||
connect: {
|
||||
id: x.cityId
|
||||
}
|
||||
id: x.cityId,
|
||||
},
|
||||
},
|
||||
monthYearReceived: x.monthYearReceived,
|
||||
negotiationStrategy: x.negotiationStrategy,
|
||||
@@ -724,8 +726,8 @@ export const offersProfileRouter = createRouter()
|
||||
jobType: x.jobType,
|
||||
location: {
|
||||
connect: {
|
||||
id: x.cityId
|
||||
}
|
||||
id: x.cityId,
|
||||
},
|
||||
},
|
||||
monthYearReceived: x.monthYearReceived,
|
||||
negotiationStrategy: x.negotiationStrategy,
|
||||
@@ -1074,8 +1076,8 @@ export const offersProfileRouter = createRouter()
|
||||
level: exp.level,
|
||||
location: {
|
||||
connect: {
|
||||
id: exp.cityId
|
||||
}
|
||||
id: exp.cityId,
|
||||
},
|
||||
},
|
||||
title: exp.title,
|
||||
totalCompensation: exp.totalCompensation
|
||||
@@ -1145,8 +1147,8 @@ export const offersProfileRouter = createRouter()
|
||||
level: exp.level,
|
||||
location: {
|
||||
connect: {
|
||||
id: exp.cityId
|
||||
}
|
||||
id: exp.cityId,
|
||||
},
|
||||
},
|
||||
title: exp.title,
|
||||
totalCompensation: {
|
||||
@@ -1213,8 +1215,8 @@ export const offersProfileRouter = createRouter()
|
||||
level: exp.level,
|
||||
location: {
|
||||
connect: {
|
||||
id: exp.cityId
|
||||
}
|
||||
id: exp.cityId,
|
||||
},
|
||||
},
|
||||
title: exp.title,
|
||||
},
|
||||
@@ -1256,8 +1258,8 @@ export const offersProfileRouter = createRouter()
|
||||
level: exp.level,
|
||||
location: {
|
||||
connect: {
|
||||
id: exp.cityId
|
||||
}
|
||||
id: exp.cityId,
|
||||
},
|
||||
},
|
||||
title: exp.title,
|
||||
},
|
||||
@@ -1305,8 +1307,8 @@ export const offersProfileRouter = createRouter()
|
||||
jobType: exp.jobType,
|
||||
location: {
|
||||
connect: {
|
||||
id: exp.cityId
|
||||
}
|
||||
id: exp.cityId,
|
||||
},
|
||||
},
|
||||
monthlySalary: {
|
||||
create: {
|
||||
@@ -1370,8 +1372,8 @@ export const offersProfileRouter = createRouter()
|
||||
jobType: exp.jobType,
|
||||
location: {
|
||||
connect: {
|
||||
id: exp.cityId
|
||||
}
|
||||
id: exp.cityId,
|
||||
},
|
||||
},
|
||||
monthlySalary: {
|
||||
create: {
|
||||
@@ -1437,7 +1439,7 @@ export const offersProfileRouter = createRouter()
|
||||
location: {
|
||||
connect: {
|
||||
id: exp.cityId,
|
||||
}
|
||||
},
|
||||
},
|
||||
title: exp.title,
|
||||
},
|
||||
@@ -1477,8 +1479,8 @@ export const offersProfileRouter = createRouter()
|
||||
jobType: exp.jobType,
|
||||
location: {
|
||||
connect: {
|
||||
id: exp.cityId
|
||||
}
|
||||
id: exp.cityId,
|
||||
},
|
||||
},
|
||||
title: exp.title,
|
||||
},
|
||||
@@ -1584,8 +1586,8 @@ export const offersProfileRouter = createRouter()
|
||||
comments: offerToUpdate.comments,
|
||||
company: {
|
||||
connect: {
|
||||
id: offerToUpdate.companyId
|
||||
}
|
||||
id: offerToUpdate.companyId,
|
||||
},
|
||||
},
|
||||
jobType:
|
||||
offerToUpdate.jobType === JobType.FULLTIME
|
||||
@@ -1593,8 +1595,8 @@ export const offersProfileRouter = createRouter()
|
||||
: JobType.INTERN,
|
||||
location: {
|
||||
connect: {
|
||||
id: offerToUpdate.cityId
|
||||
}
|
||||
id: offerToUpdate.cityId,
|
||||
},
|
||||
},
|
||||
monthYearReceived: offerToUpdate.monthYearReceived,
|
||||
negotiationStrategy: offerToUpdate.negotiationStrategy,
|
||||
@@ -1820,8 +1822,8 @@ export const offersProfileRouter = createRouter()
|
||||
jobType: offerToUpdate.jobType,
|
||||
location: {
|
||||
connect: {
|
||||
id: offerToUpdate.cityId
|
||||
}
|
||||
id: offerToUpdate.cityId,
|
||||
},
|
||||
},
|
||||
monthYearReceived: offerToUpdate.monthYearReceived,
|
||||
negotiationStrategy: offerToUpdate.negotiationStrategy,
|
||||
@@ -1878,8 +1880,8 @@ export const offersProfileRouter = createRouter()
|
||||
jobType: offerToUpdate.jobType,
|
||||
location: {
|
||||
connect: {
|
||||
id: offerToUpdate.cityId
|
||||
}
|
||||
id: offerToUpdate.cityId,
|
||||
},
|
||||
},
|
||||
monthYearReceived: offerToUpdate.monthYearReceived,
|
||||
negotiationStrategy: offerToUpdate.negotiationStrategy,
|
||||
|
||||
@@ -292,7 +292,7 @@ export const generateAnalysis = async (params: {
|
||||
: similarCompanyOffers;
|
||||
|
||||
return {
|
||||
companyName: companyOffer.company.name,
|
||||
companyId: companyOffer.companyId,
|
||||
noOfSimilarOffers: noOfSimilarCompanyOffers,
|
||||
percentile: companyPercentile,
|
||||
topSimilarOffers: topPercentileCompanyOffers,
|
||||
@@ -329,7 +329,11 @@ export const generateAnalysis = async (params: {
|
||||
companyAnalysis: {
|
||||
create: companyAnalysis.map((analysisUnit) => {
|
||||
return {
|
||||
companyName: analysisUnit.companyName,
|
||||
company: {
|
||||
connect: {
|
||||
id: analysisUnit.companyId,
|
||||
},
|
||||
},
|
||||
noOfSimilarOffers: analysisUnit.noOfSimilarOffers,
|
||||
percentile: analysisUnit.percentile,
|
||||
topSimilarOffers: {
|
||||
@@ -342,7 +346,11 @@ export const generateAnalysis = async (params: {
|
||||
},
|
||||
overallAnalysis: {
|
||||
create: {
|
||||
companyName: overallHighestOffer.company.name,
|
||||
company: {
|
||||
connect: {
|
||||
id: overallHighestOffer.companyId,
|
||||
},
|
||||
},
|
||||
noOfSimilarOffers,
|
||||
percentile: overallPercentile,
|
||||
topSimilarOffers: {
|
||||
@@ -366,6 +374,7 @@ export const generateAnalysis = async (params: {
|
||||
include: {
|
||||
companyAnalysis: {
|
||||
include: {
|
||||
company: true,
|
||||
topSimilarOffers: {
|
||||
include: {
|
||||
company: true,
|
||||
@@ -416,6 +425,7 @@ export const generateAnalysis = async (params: {
|
||||
},
|
||||
overallAnalysis: {
|
||||
include: {
|
||||
company: true,
|
||||
topSimilarOffers: {
|
||||
include: {
|
||||
company: true,
|
||||
|
||||
Reference in New Issue
Block a user