[offers][chore] Add reference to analysed offer in analysis unit (#504)

Co-authored-by: Bryann Yeap Kok Keong <bryannyeapkk@gmail.com>
pull/511/head
Bryann Yeap Kok Keong 2 years ago committed by GitHub
parent a7b4daec21
commit 80fd274662
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

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

@ -104,7 +104,6 @@ model Company {
questionsQuestionEncounter QuestionsQuestionEncounter[] questionsQuestionEncounter QuestionsQuestionEncounter[]
OffersExperience OffersExperience[] OffersExperience OffersExperience[]
OffersOffer OffersOffer[] OffersOffer OffersOffer[]
OffersAnalysisUnit OffersAnalysisUnit[]
} }
model Country { model Country {
@ -368,6 +367,7 @@ model OffersOffer {
offersAnalysis OffersAnalysis? @relation("HighestOverallOffer") offersAnalysis OffersAnalysis? @relation("HighestOverallOffer")
offersAnalysisUnit OffersAnalysisUnit[] offersAnalysisUnit OffersAnalysisUnit[]
OffersAnalysisUnit OffersAnalysisUnit[] @relation("Analysed Offer")
} }
model OffersIntern { model OffersIntern {
@ -419,8 +419,8 @@ model OffersAnalysis {
model OffersAnalysisUnit { model OffersAnalysisUnit {
id String @id @default(cuid()) id String @id @default(cuid())
company Company @relation(fields: [companyId], references: [id]) analysedOffer OffersOffer @relation("Analysed Offer", fields: [analysedOfferId], references: [id])
companyId String analysedOfferId String
percentile Float percentile Float
noOfSimilarOffers Int noOfSimilarOffers Int

@ -133,7 +133,14 @@ const analysisOfferDtoMapper = (
const analysisUnitDtoMapper = ( const analysisUnitDtoMapper = (
analysisUnit: OffersAnalysisUnit & { analysisUnit: OffersAnalysisUnit & {
company: Company; analysedOffer: OffersOffer & {
company: Company;
offersFullTime:
| (OffersFullTime & { totalCompensation: OffersCurrency })
| null;
offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null;
profile: OffersProfile & { background: OffersBackground | null };
};
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;
@ -161,7 +168,7 @@ const analysisUnitDtoMapper = (
}, },
) => { ) => {
const analysisDto: AnalysisUnit = { const analysisDto: AnalysisUnit = {
companyName: analysisUnit.company.name, companyName: analysisUnit.analysedOffer.company.name,
noOfOffers: analysisUnit.noOfSimilarOffers, noOfOffers: analysisUnit.noOfSimilarOffers,
percentile: analysisUnit.percentile, percentile: analysisUnit.percentile,
topPercentileOffers: analysisUnit.topSimilarOffers.map((offer) => topPercentileOffers: analysisUnit.topSimilarOffers.map((offer) =>
@ -197,7 +204,16 @@ export const profileAnalysisDtoMapper = (
| (OffersAnalysis & { | (OffersAnalysis & {
companyAnalysis: Array< companyAnalysis: Array<
OffersAnalysisUnit & { OffersAnalysisUnit & {
company: Company; analysedOffer: OffersOffer & {
company: Company;
offersFullTime:
| (OffersFullTime & { totalCompensation: OffersCurrency })
| null;
offersIntern:
| (OffersIntern & { monthlySalary: OffersCurrency })
| null;
profile: OffersProfile & { background: OffersBackground | null };
};
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;
@ -227,7 +243,16 @@ export const profileAnalysisDtoMapper = (
} }
>; >;
overallAnalysis: OffersAnalysisUnit & { overallAnalysis: OffersAnalysisUnit & {
company: Company; analysedOffer: OffersOffer & {
company: Company;
offersFullTime:
| (OffersFullTime & { totalCompensation: OffersCurrency })
| null;
offersIntern:
| (OffersIntern & { monthlySalary: OffersCurrency })
| null;
profile: OffersProfile & { background: OffersBackground | null };
};
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;
@ -513,7 +538,18 @@ export const profileDtoMapper = (
| (OffersAnalysis & { | (OffersAnalysis & {
companyAnalysis: Array< companyAnalysis: Array<
OffersAnalysisUnit & { OffersAnalysisUnit & {
company: Company; analysedOffer: OffersOffer & {
company: Company;
offersFullTime:
| (OffersFullTime & { totalCompensation: OffersCurrency })
| null;
offersIntern:
| (OffersIntern & { monthlySalary: OffersCurrency })
| null;
profile: OffersProfile & {
background: OffersBackground | null;
};
};
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;
@ -545,7 +581,16 @@ export const profileDtoMapper = (
} }
>; >;
overallAnalysis: OffersAnalysisUnit & { overallAnalysis: OffersAnalysisUnit & {
company: Company; analysedOffer: OffersOffer & {
company: Company;
offersFullTime:
| (OffersFullTime & { totalCompensation: OffersCurrency })
| null;
offersIntern:
| (OffersIntern & { monthlySalary: OffersCurrency })
| null;
profile: OffersProfile & { background: OffersBackground | null };
};
topSimilarOffers: Array< topSimilarOffers: Array<
OffersOffer & { OffersOffer & {
company: Company; company: Company;

@ -2,9 +2,10 @@ import { z } from 'zod';
import { TRPCError } from '@trpc/server'; import { TRPCError } from '@trpc/server';
import { profileAnalysisDtoMapper } from '~/mappers/offers-mappers'; import { profileAnalysisDtoMapper } from '~/mappers/offers-mappers';
import { analysisInclusion } from '~/utils/offers/analysis/analysisInclusion';
import { createRouter } from '../context'; import { createRouter } from '../context';
import { generateAnalysis } from '../../../utils/offers/analysisGeneration'; import { generateAnalysis } from '../../../utils/offers/analysis/analysisGeneration';
export const offersAnalysisRouter = createRouter() export const offersAnalysisRouter = createRouter()
.query('get', { .query('get', {
@ -13,139 +14,7 @@ export const offersAnalysisRouter = createRouter()
}), }),
async resolve({ ctx, input }) { async resolve({ ctx, input }) {
const analysis = await ctx.prisma.offersAnalysis.findFirst({ const analysis = await ctx.prisma.offersAnalysis.findFirst({
include: { include: analysisInclusion,
companyAnalysis: {
include: {
company: true,
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallAnalysis: {
include: {
company: true,
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallHighestOffer: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: true,
},
},
},
},
},
where: { where: {
profileId: input.profileId, profileId: input.profileId,
}, },

@ -8,6 +8,7 @@ import {
createOfferProfileResponseMapper, createOfferProfileResponseMapper,
profileDtoMapper, profileDtoMapper,
} from '~/mappers/offers-mappers'; } from '~/mappers/offers-mappers';
import { analysisInclusion } from '~/utils/offers/analysis/analysisInclusion';
import { baseCurrencyString } from '~/utils/offers/currency'; import { baseCurrencyString } from '~/utils/offers/currency';
import { convert } from '~/utils/offers/currency/currencyExchange'; import { convert } from '~/utils/offers/currency/currencyExchange';
import { import {
@ -165,139 +166,7 @@ export const offersProfileRouter = createRouter()
const result = await ctx.prisma.offersProfile.findFirst({ const result = await ctx.prisma.offersProfile.findFirst({
include: { include: {
analysis: { analysis: {
include: { include: analysisInclusion,
companyAnalysis: {
include: {
company: true,
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallAnalysis: {
include: {
company: true,
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallHighestOffer: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: true,
},
},
},
},
},
}, },
background: { background: {
include: { include: {
@ -974,9 +843,9 @@ export const offersProfileRouter = createRouter()
if (exp.id) { if (exp.id) {
const currentExp = await ctx.prisma.offersExperience.findFirst({ const currentExp = await ctx.prisma.offersExperience.findFirst({
where: { where: {
id: exp.id id: exp.id,
} },
}) });
if (!currentExp) { if (!currentExp) {
throw new trpc.TRPCError({ throw new trpc.TRPCError({
@ -1107,53 +976,53 @@ export const offersProfileRouter = createRouter()
totalCompensationId: null, totalCompensationId: null,
}, },
where: { where: {
id: exp.id id: exp.id,
} },
}) });
} else if (exp.jobType === JobType.FULLTIME) { } else if (exp.jobType === JobType.FULLTIME) {
if (exp.totalCompensation) { if (exp.totalCompensation) {
await ctx.prisma.offersExperience.update({ await ctx.prisma.offersExperience.update({
data: { data: {
totalCompensation: { totalCompensation: {
upsert: { upsert: {
create: { create: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
exp.totalCompensation.value, exp.totalCompensation.value,
exp.totalCompensation.currency, exp.totalCompensation.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: exp.totalCompensation.currency, currency: exp.totalCompensation.currency,
value: exp.totalCompensation.value, value: exp.totalCompensation.value,
}, },
update: { update: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
exp.totalCompensation.value, exp.totalCompensation.value,
exp.totalCompensation.currency, exp.totalCompensation.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: exp.totalCompensation.currency, currency: exp.totalCompensation.currency,
value: exp.totalCompensation.value, value: exp.totalCompensation.value,
},
}, },
}, },
}, },
where: {
id: exp.id,
},
});
}
await ctx.prisma.offersExperience.update({
data: {
monthlySalary: undefined,
monthlySalaryId: null
}, },
where: { where: {
id: exp.id id: exp.id,
} },
}) });
}
await ctx.prisma.offersExperience.update({
data: {
monthlySalary: undefined,
monthlySalaryId: null,
},
where: {
id: exp.id,
},
});
} }
} else if (!exp.id) { } else if (!exp.id) {
// Create new experience // Create new experience
@ -1686,9 +1555,9 @@ export const offersProfileRouter = createRouter()
// Update existing offer // Update existing offer
const currentOffer = await ctx.prisma.offersOffer.findFirst({ const currentOffer = await ctx.prisma.offersOffer.findFirst({
where: { where: {
id: offerToUpdate.id id: offerToUpdate.id,
} },
}) });
if (!currentOffer) { if (!currentOffer) {
throw new trpc.TRPCError({ throw new trpc.TRPCError({
@ -1753,7 +1622,8 @@ export const offersProfileRouter = createRouter()
}, },
}, },
}, },
startYear: offerToUpdate.offersIntern.startYear ?? undefined, startYear:
offerToUpdate.offersIntern.startYear ?? undefined,
title: offerToUpdate.offersIntern.title, title: offerToUpdate.offersIntern.title,
}, },
where: { where: {
@ -1786,7 +1656,8 @@ export const offersProfileRouter = createRouter()
), ),
currency: currency:
offerToUpdate.offersFullTime.baseSalary.currency, offerToUpdate.offersFullTime.baseSalary.currency,
value: offerToUpdate.offersFullTime.baseSalary.value, value:
offerToUpdate.offersFullTime.baseSalary.value,
}, },
update: { update: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
@ -1797,7 +1668,8 @@ export const offersProfileRouter = createRouter()
), ),
currency: currency:
offerToUpdate.offersFullTime.baseSalary.currency, offerToUpdate.offersFullTime.baseSalary.currency,
value: offerToUpdate.offersFullTime.baseSalary.value, value:
offerToUpdate.offersFullTime.baseSalary.value,
}, },
}, },
}, },
@ -1819,7 +1691,8 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersFullTime.bonus.currency, offerToUpdate.offersFullTime.bonus.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersFullTime.bonus.currency, currency:
offerToUpdate.offersFullTime.bonus.currency,
value: offerToUpdate.offersFullTime.bonus.value, value: offerToUpdate.offersFullTime.bonus.value,
}, },
update: { update: {
@ -1829,7 +1702,8 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersFullTime.bonus.currency, offerToUpdate.offersFullTime.bonus.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersFullTime.bonus.currency, currency:
offerToUpdate.offersFullTime.bonus.currency,
value: offerToUpdate.offersFullTime.bonus.value, value: offerToUpdate.offersFullTime.bonus.value,
}, },
}, },
@ -1882,7 +1756,8 @@ export const offersProfileRouter = createRouter()
create: { create: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
offerToUpdate.offersFullTime.totalCompensation.value, offerToUpdate.offersFullTime.totalCompensation
.value,
offerToUpdate.offersFullTime.totalCompensation offerToUpdate.offersFullTime.totalCompensation
.currency, .currency,
baseCurrencyString, baseCurrencyString,
@ -1891,12 +1766,14 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersFullTime.totalCompensation offerToUpdate.offersFullTime.totalCompensation
.currency, .currency,
value: value:
offerToUpdate.offersFullTime.totalCompensation.value, offerToUpdate.offersFullTime.totalCompensation
.value,
}, },
update: { update: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
offerToUpdate.offersFullTime.totalCompensation.value, offerToUpdate.offersFullTime.totalCompensation
.value,
offerToUpdate.offersFullTime.totalCompensation offerToUpdate.offersFullTime.totalCompensation
.currency, .currency,
baseCurrencyString, baseCurrencyString,
@ -1905,7 +1782,8 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersFullTime.totalCompensation offerToUpdate.offersFullTime.totalCompensation
.currency, .currency,
value: value:
offerToUpdate.offersFullTime.totalCompensation.value, offerToUpdate.offersFullTime.totalCompensation
.value,
}, },
}, },
}, },
@ -1940,7 +1818,8 @@ export const offersProfileRouter = createRouter()
), ),
currency: currency:
offerToUpdate.offersFullTime.baseSalary.currency, offerToUpdate.offersFullTime.baseSalary.currency,
value: offerToUpdate.offersFullTime.baseSalary.value, value:
offerToUpdate.offersFullTime.baseSalary.value,
}, },
update: { update: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
@ -1951,7 +1830,8 @@ export const offersProfileRouter = createRouter()
), ),
currency: currency:
offerToUpdate.offersFullTime.baseSalary.currency, offerToUpdate.offersFullTime.baseSalary.currency,
value: offerToUpdate.offersFullTime.baseSalary.value, value:
offerToUpdate.offersFullTime.baseSalary.value,
}, },
}, },
}, },
@ -1973,7 +1853,8 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersFullTime.bonus.currency, offerToUpdate.offersFullTime.bonus.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersFullTime.bonus.currency, currency:
offerToUpdate.offersFullTime.bonus.currency,
value: offerToUpdate.offersFullTime.bonus.value, value: offerToUpdate.offersFullTime.bonus.value,
}, },
update: { update: {
@ -1983,7 +1864,8 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersFullTime.bonus.currency, offerToUpdate.offersFullTime.bonus.currency,
baseCurrencyString, baseCurrencyString,
), ),
currency: offerToUpdate.offersFullTime.bonus.currency, currency:
offerToUpdate.offersFullTime.bonus.currency,
value: offerToUpdate.offersFullTime.bonus.value, value: offerToUpdate.offersFullTime.bonus.value,
}, },
}, },
@ -2036,7 +1918,8 @@ export const offersProfileRouter = createRouter()
create: { create: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
offerToUpdate.offersFullTime.totalCompensation.value, offerToUpdate.offersFullTime.totalCompensation
.value,
offerToUpdate.offersFullTime.totalCompensation offerToUpdate.offersFullTime.totalCompensation
.currency, .currency,
baseCurrencyString, baseCurrencyString,
@ -2045,12 +1928,14 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersFullTime.totalCompensation offerToUpdate.offersFullTime.totalCompensation
.currency, .currency,
value: value:
offerToUpdate.offersFullTime.totalCompensation.value, offerToUpdate.offersFullTime.totalCompensation
.value,
}, },
update: { update: {
baseCurrency: baseCurrencyString, baseCurrency: baseCurrencyString,
baseValue: await convert( baseValue: await convert(
offerToUpdate.offersFullTime.totalCompensation.value, offerToUpdate.offersFullTime.totalCompensation
.value,
offerToUpdate.offersFullTime.totalCompensation offerToUpdate.offersFullTime.totalCompensation
.currency, .currency,
baseCurrencyString, baseCurrencyString,
@ -2059,7 +1944,8 @@ export const offersProfileRouter = createRouter()
offerToUpdate.offersFullTime.totalCompensation offerToUpdate.offersFullTime.totalCompensation
.currency, .currency,
value: value:
offerToUpdate.offersFullTime.totalCompensation.value, offerToUpdate.offersFullTime.totalCompensation
.value,
}, },
}, },
}, },
@ -2073,12 +1959,12 @@ export const offersProfileRouter = createRouter()
await ctx.prisma.offersOffer.update({ await ctx.prisma.offersOffer.update({
data: { data: {
offersIntern: undefined, offersIntern: undefined,
offersInternId: null offersInternId: null,
}, },
where: { where: {
id: offerToUpdate.id id: offerToUpdate.id,
} },
}) });
} else if (currentOffer.jobType === JobType.INTERN) { } else if (currentOffer.jobType === JobType.INTERN) {
if (offerToUpdate.offersIntern?.monthlySalary != null) { if (offerToUpdate.offersIntern?.monthlySalary != null) {
await ctx.prisma.offersIntern.update({ await ctx.prisma.offersIntern.update({
@ -2111,7 +1997,8 @@ export const offersProfileRouter = createRouter()
}, },
}, },
}, },
startYear: offerToUpdate.offersIntern.startYear ?? undefined, startYear:
offerToUpdate.offersIntern.startYear ?? undefined,
title: offerToUpdate.offersIntern.title, title: offerToUpdate.offersIntern.title,
}, },
where: { where: {
@ -2123,12 +2010,12 @@ export const offersProfileRouter = createRouter()
await ctx.prisma.offersOffer.update({ await ctx.prisma.offersOffer.update({
data: { data: {
offersFullTime: undefined, offersFullTime: undefined,
offersFullTimeId: null offersFullTimeId: null,
}, },
where: { where: {
id: offerToUpdate.id id: offerToUpdate.id,
} },
}) });
} }
} else { } else {
// Create new offer // Create new offer

@ -15,7 +15,8 @@ import type {
} from '@prisma/client'; } from '@prisma/client';
import { TRPCError } from '@trpc/server'; import { TRPCError } from '@trpc/server';
import { profileAnalysisDtoMapper } from '../../mappers/offers-mappers'; import { analysisInclusion } from './analysisInclusion';
import { profileAnalysisDtoMapper } from '../../../mappers/offers-mappers';
type Offer = OffersOffer & { type Offer = OffersOffer & {
company: Company; company: Company;
@ -292,7 +293,7 @@ export const generateAnalysis = async (params: {
: similarCompanyOffers; : similarCompanyOffers;
return { return {
companyId: companyOffer.companyId, analysedOfferId: companyOffer.id,
noOfSimilarOffers: noOfSimilarCompanyOffers, noOfSimilarOffers: noOfSimilarCompanyOffers,
percentile: companyPercentile, percentile: companyPercentile,
topSimilarOffers: topPercentileCompanyOffers, topSimilarOffers: topPercentileCompanyOffers,
@ -329,9 +330,9 @@ export const generateAnalysis = async (params: {
companyAnalysis: { companyAnalysis: {
create: companyAnalysis.map((analysisUnit) => { create: companyAnalysis.map((analysisUnit) => {
return { return {
company: { analysedOffer: {
connect: { connect: {
id: analysisUnit.companyId, id: analysisUnit.analysedOfferId,
}, },
}, },
noOfSimilarOffers: analysisUnit.noOfSimilarOffers, noOfSimilarOffers: analysisUnit.noOfSimilarOffers,
@ -346,9 +347,9 @@ export const generateAnalysis = async (params: {
}, },
overallAnalysis: { overallAnalysis: {
create: { create: {
company: { analysedOffer: {
connect: { connect: {
id: overallHighestOffer.companyId, id: overallHighestOffer.id,
}, },
}, },
noOfSimilarOffers, noOfSimilarOffers,
@ -371,139 +372,7 @@ export const generateAnalysis = async (params: {
}, },
}, },
}, },
include: { include: analysisInclusion,
companyAnalysis: {
include: {
company: true,
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallAnalysis: {
include: {
company: true,
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallHighestOffer: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: true,
},
},
},
},
},
}); });
return profileAnalysisDtoMapper(analysis); return profileAnalysisDtoMapper(analysis);

@ -0,0 +1,171 @@
export const analysisInclusion = {
companyAnalysis: {
include: {
analysedOffer: {
include: {
company: true,
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: true,
},
},
},
},
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallAnalysis: {
include: {
analysedOffer: {
include: {
company: true,
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: true,
},
},
},
},
topSimilarOffers: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: {
include: {
experiences: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
},
},
},
},
},
},
},
},
},
},
overallHighestOffer: {
include: {
company: true,
location: {
include: {
state: {
include: {
country: true,
},
},
},
},
offersFullTime: {
include: {
totalCompensation: true,
},
},
offersIntern: {
include: {
monthlySalary: true,
},
},
profile: {
include: {
background: true,
},
},
},
},
};
Loading…
Cancel
Save