diff --git a/apps/portal/src/components/offers/constants.ts b/apps/portal/src/components/offers/constants.ts
index ceb3c3e7..48d9bf48 100644
--- a/apps/portal/src/components/offers/constants.ts
+++ b/apps/portal/src/components/offers/constants.ts
@@ -5,84 +5,10 @@ export const JobTypeLabel = {
INTERN: 'Internship',
};
-<<<<<<< HEAD
export const emptyOption = {
label: '',
value: '',
};
-=======
-export const internshipCycleOptions = [
- {
- label: 'Summer',
- value: 'Summer',
- },
- {
- label: 'Winter',
- value: 'Winter',
- },
- {
- label: 'Spring',
- value: 'Spring',
- },
- {
- label: 'Fall',
- value: 'Fall',
- },
- {
- label: 'Full year',
- value: 'Full year',
- },
-];
-
-export const yearOptions = [
- {
- label: '2021',
- value: 2021,
- },
- {
- label: '2022',
- value: 2022,
- },
- {
- label: '2023',
- value: 2023,
- },
- {
- label: '2024',
- value: 2024,
- },
-];
-
-export const educationLevelOptions = Object.entries(
- EducationBackgroundType,
-).map(([, value]) => ({
- label: value,
- value,
-}));
-
-export const educationFieldOptions = [
- {
- label: 'Computer Science',
- value: 'Computer Science',
- },
- {
- label: 'Information Security',
- value: 'Information Security',
- },
- {
- label: 'Information Systems',
- value: 'Information Systems',
- },
- {
- label: 'Business Analytics',
- value: 'Business Analytics',
- },
- {
- label: 'Data Science and Analytics',
- value: 'Data Science and Analytics',
- },
-];
->>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field)
export enum FieldError {
NON_NEGATIVE_NUMBER = 'Please fill in a non-negative number in this field.',
@@ -111,4 +37,4 @@ export const profileDetailTabs = [
label: ProfileDetailTab.ANALYSIS,
value: ProfileDetailTab.ANALYSIS,
},
-];
+];
\ No newline at end of file
diff --git a/apps/portal/src/components/offers/dashboard/DashboardOfferCard.tsx b/apps/portal/src/components/offers/dashboard/DashboardOfferCard.tsx
index a901aba7..1085b7e9 100644
--- a/apps/portal/src/components/offers/dashboard/DashboardOfferCard.tsx
+++ b/apps/portal/src/components/offers/dashboard/DashboardOfferCard.tsx
@@ -33,7 +33,6 @@ export default function DashboardProfileCard({
-<<<<<<< HEAD
{getLabelForJobTitleType(title as JobTitleType)}{' '}
{jobType && <>({JobTypeLabel[jobType]})>}
@@ -67,17 +66,6 @@ export default function DashboardProfileCard({
)}
-=======
-
- {getLabelForJobTitleType(title as JobTitleType)}
-
-
- {location
- ? `Company: ${company.name}, ${location.cityName}`
- : `Company: ${company.name}`}
-
- {level &&
Level: {level}
}
->>>>>>> ac2d047d ([offers][feat] integrate location for offer table and profile)
@@ -92,4 +80,4 @@ export default function DashboardProfileCard({
);
-}
+}
\ No newline at end of file
diff --git a/apps/portal/src/components/offers/offersSubmission/OffersSubmissionForm.tsx b/apps/portal/src/components/offers/offersSubmission/OffersSubmissionForm.tsx
index 313fedfd..bef36c36 100644
--- a/apps/portal/src/components/offers/offersSubmission/OffersSubmissionForm.tsx
+++ b/apps/portal/src/components/offers/offersSubmission/OffersSubmissionForm.tsx
@@ -289,7 +289,6 @@ export default function OffersSubmissionForm({
steps={breadcrumbSteps}
/>
-<<<<<<< HEAD
-=======
-
-
-
->>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field)
);
-}
+}
\ No newline at end of file
diff --git a/apps/portal/src/components/offers/offersSubmission/submissionForm/BackgroundForm.tsx b/apps/portal/src/components/offers/offersSubmission/submissionForm/BackgroundForm.tsx
index 24d2ec86..e8d6cb50 100644
--- a/apps/portal/src/components/offers/offersSubmission/submissionForm/BackgroundForm.tsx
+++ b/apps/portal/src/components/offers/offersSubmission/submissionForm/BackgroundForm.tsx
@@ -2,16 +2,7 @@ import { useFormContext, useWatch } from 'react-hook-form';
import { JobType } from '@prisma/client';
import { Collapsible, RadioList } from '@tih/ui';
-<<<<<<< HEAD
import { FieldError } from '~/components/offers/constants';
-=======
-import {
- educationFieldOptions,
- educationLevelOptions,
- emptyOption,
- FieldError,
-} from '~/components/offers/constants';
->>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field)
import type { BackgroundPostData } from '~/components/offers/types';
import CitiesTypeahead from '~/components/shared/CitiesTypeahead';
import CompaniesTypeahead from '~/components/shared/CompaniesTypeahead';
@@ -264,7 +255,6 @@ function InternshipJobFields() {
}}
/>
-<<<<<<< HEAD
-=======
-
-
->>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field)
>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field)
/>
@@ -405,4 +388,4 @@ export default function BackgroundForm() {
);
-}
+}
\ No newline at end of file
diff --git a/apps/portal/src/components/offers/offersSubmission/submissionForm/OfferDetailsForm.tsx b/apps/portal/src/components/offers/offersSubmission/submissionForm/OfferDetailsForm.tsx
index 22bef95a..5cfee9e8 100644
--- a/apps/portal/src/components/offers/offersSubmission/submissionForm/OfferDetailsForm.tsx
+++ b/apps/portal/src/components/offers/offersSubmission/submissionForm/OfferDetailsForm.tsx
@@ -22,16 +22,7 @@ import {
defaultFullTimeOfferValues,
defaultInternshipOfferValues,
} from '../OffersSubmissionForm';
-<<<<<<< HEAD
import { FieldError, JobTypeLabel } from '../../constants';
-=======
-import {
- emptyOption,
- FieldError,
- internshipCycleOptions,
- yearOptions,
-} from '../../constants';
->>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field)
import FormMonthYearPicker from '../../forms/FormMonthYearPicker';
import FormSection from '../../forms/FormSection';
import FormSelect from '../../forms/FormSelect';
@@ -115,7 +106,6 @@ function FullTimeOfferDetailsForm({
})}
/>
-<<<<<<< HEAD
-
-
- {
- if (option) {
- setValue(`offers.${index}.companyId`, option.value);
- setValue(`offers.${index}.companyName`, option.label);
- }
- }}
- />
- {
- if (option) {
- setValue(`offers.${index}.cityId`, option.value);
- setValue(`offers.${index}.cityName`, option.label);
- } else {
- setValue(`offers.${index}.cityId`, '');
- setValue(`offers.${index}.cityName`, '');
- }
- }}
- />
-
-
-
-
-
-
- }
- endAddOnType="element"
- errorMessage={
- offerFields?.offersFullTime?.totalCompensation?.value?.message
- }
- label="Total Compensation (Annual)"
- placeholder="0"
- required={true}
- startAddOn="$"
- startAddOnType="label"
- type="number"
- {...register(
- `offers.${index}.offersFullTime.totalCompensation.value`,
- {
- min: { message: FieldError.NON_NEGATIVE_NUMBER, value: 0 },
->>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field)
required: FieldError.REQUIRED,
})}
/>
@@ -472,7 +375,6 @@ function InternshipOfferDetailsForm({
}}
/>
-<<<<<<< HEAD
-=======
- {
- if (option) {
- setValue(`offers.${index}.cityId`, option.value);
- setValue(`offers.${index}.cityName`, option.label);
- } else {
- setValue(`offers.${index}.cityId`, '');
- setValue(`offers.${index}.cityName`, '');
- }
- }}
- />
-
-
-
-
-
-
-
-
-
-
- }
- endAddOnType="element"
- errorMessage={
- offerFields?.offersIntern?.monthlySalary?.value?.message
- }
- label="Salary (Monthly)"
- placeholder="0"
- required={true}
- startAddOn="$"
- startAddOnType="label"
- type="number"
- {...register(`offers.${index}.offersIntern.monthlySalary.value`, {
- min: { message: FieldError.NON_NEGATIVE_NUMBER, value: 0 },
- required: FieldError.REQUIRED,
- valueAsNumber: true,
- })}
- />
-
-
->>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field)
);
-}
+}
\ No newline at end of file
diff --git a/apps/portal/src/components/offers/profile/OfferCard.tsx b/apps/portal/src/components/offers/profile/OfferCard.tsx
index 0668716f..2ed305f3 100644
--- a/apps/portal/src/components/offers/profile/OfferCard.tsx
+++ b/apps/portal/src/components/offers/profile/OfferCard.tsx
@@ -35,7 +35,6 @@ export default function OfferCard({
}: Props) {
function UpperSection() {
return (
-<<<<<<< HEAD
@@ -71,17 +70,6 @@ export default function OfferCard({
)}
-=======
-
-
-
-
-
-
-
- {location ? `${companyName}, ${location.cityName}` : companyName}
-
->>>>>>> ac2d047d ([offers][feat] integrate location for offer table and profile)
{!duration && receivedMonth && (
@@ -111,7 +99,6 @@ export default function OfferCard({
}
return (
-<<<<<<< HEAD
{jobType === JobType.FULLTIME
@@ -155,34 +142,6 @@ export default function OfferCard({
{bonus}
)}
-=======
- <>
-
-
-
- {(totalCompensation || monthlySalary) && (
-
-
-
-
-
-
- {totalCompensation && `TC: ${totalCompensation}`}
- {monthlySalary && `Monthly Salary: ${monthlySalary}`}
-
-
-
- )}
- {(base || stocks || bonus) && totalCompensation && (
-
-
- Base / year: {base ?? 'N/A'} ⋅ Stocks / year:{' '}
- {stocks ?? 'N/A'} ⋅ Bonus / year: {bonus ?? 'N/A'}
-
-
- )}
-
->>>>>>> ac2d047d ([offers][feat] integrate location for offer table and profile)
{negotiationStrategy && (
@@ -210,4 +169,4 @@ export default function OfferCard({
);
-}
+}
\ No newline at end of file
diff --git a/apps/portal/src/components/offers/table/OffersTable.tsx b/apps/portal/src/components/offers/table/OffersTable.tsx
index 6023ed36..532946a8 100644
--- a/apps/portal/src/components/offers/table/OffersTable.tsx
+++ b/apps/portal/src/components/offers/table/OffersTable.tsx
@@ -25,19 +25,14 @@ import type { DashboardOffer, GetOffersResponse, Paging } from '~/types/offers';
const NUMBER_OF_OFFERS_IN_PAGE = 10;
export type OffersTableProps = Readonly<{
- cityFilter: string;
companyFilter: string;
companyName?: string;
countryFilter: string;
jobTitleFilter: string;
}>;
export default function OffersTable({
-<<<<<<< HEAD
countryFilter,
companyName,
-=======
- cityFilter,
->>>>>>> ac2d047d ([offers][feat] integrate location for offer table and profile)
companyFilter,
jobTitleFilter,
}: OffersTableProps) {
@@ -111,8 +106,6 @@ export default function OffersTable({
[
'offers.list',
{
- // Location: 'Singapore, Singapore', // TODO: Geolocation
- cityId: cityFilter,
companyId: companyFilter,
countryId: countryFilter,
currency,
@@ -172,17 +165,11 @@ export default function OffersTable({
/>
))}
-<<<<<<< HEAD
Display offers in
-=======
-
-
- Display offers in
->>>>>>> ac2d047d ([offers][feat] integrate location for offer table and profile)
setCurrency(value)}
selectedCurrency={currency}
@@ -303,4 +290,4 @@ export default function OffersTable({
/>
);
-}
+}
\ No newline at end of file
diff --git a/apps/portal/src/components/offers/table/types.ts b/apps/portal/src/components/offers/table/types.ts
index e9a8c42e..1be3d1e7 100644
--- a/apps/portal/src/components/offers/table/types.ts
+++ b/apps/portal/src/components/offers/table/types.ts
@@ -56,4 +56,4 @@ export type OfferTableSortByType =
| '-monthYearReceived'
| '-totalCompensation'
| '-totalYoe'
- | '+totalYoe';
+ | '+totalYoe';
\ No newline at end of file
diff --git a/apps/portal/src/components/offers/types.ts b/apps/portal/src/components/offers/types.ts
index e8a45b4c..f7698da1 100644
--- a/apps/portal/src/components/offers/types.ts
+++ b/apps/portal/src/components/offers/types.ts
@@ -3,30 +3,6 @@ import type { JobType } from '@prisma/client';
import type { MonthYear } from '~/components/shared/MonthYearPicker';
import type { Location } from '~/types/offers';
-<<<<<<< HEAD
-=======
-
-export const HOME_URL = '/offers';
-
-/*
- * Offer Profile
- */
-
-export const JobTypeLabel = {
- FULLTIME: 'Full-time',
- INTERN: 'Internship',
-};
-
-export enum EducationBackgroundType {
- Bachelor = 'Bachelor',
- Diploma = 'Diploma',
- Masters = 'Masters',
- PhD = 'PhD',
- Professional = 'Professional',
- Secondary = 'Secondary',
- SelfTaught = 'Self-taught',
-}
->>>>>>> ac2d047d ([offers][feat] integrate location for offer table and profile)
export type OffersProfilePostData = {
background: BackgroundPostData;
@@ -57,13 +33,6 @@ type ExperiencePostData = {
id?: string;
jobType?: string | null;
level?: string | null;
-<<<<<<< HEAD
-<<<<<<< HEAD
-=======
- location?: Location | null;
->>>>>>> ac2d047d ([offers][feat] integrate location for offer table and profile)
-=======
->>>>>>> a31230f7 ([offers][feat] Use city typeahead for location field)
monthlySalary?: Money | null;
title?: string | null;
totalCompensation?: Money | null;
@@ -172,4 +141,4 @@ export type CommentEntity = {
replyingToId: string;
userId: string;
username: string;
-};
+};
\ No newline at end of file
diff --git a/apps/portal/src/pages/offers/index.tsx b/apps/portal/src/pages/offers/index.tsx
index 6028db6e..232fd382 100644
--- a/apps/portal/src/pages/offers/index.tsx
+++ b/apps/portal/src/pages/offers/index.tsx
@@ -5,7 +5,6 @@ import { Banner } from '@tih/ui';
import { useGoogleAnalytics } from '~/components/global/GoogleAnalytics';
import OffersTable from '~/components/offers/table/OffersTable';
-import CitiesTypeahead from '~/components/shared/CitiesTypeahead';
import CompaniesTypeahead from '~/components/shared/CompaniesTypeahead';
import Container from '~/components/shared/Container';
import CountriesTypeahead from '~/components/shared/CountriesTypeahead';
@@ -13,22 +12,10 @@ import type { JobTitleType } from '~/components/shared/JobTitles';
import { JobTitleLabels } from '~/components/shared/JobTitles';
import JobTitlesTypeahead from '~/components/shared/JobTitlesTypahead';
-<<<<<<< HEAD
-<<<<<<< HEAD
import { useSearchParamSingle } from '~/utils/offers/useSearchParam';
export default function OffersHomePage() {
const [countryFilter, setCountryFilter] = useState('');
-=======
-import CitiesTypeahead from '../../components/shared/CitiesTypeahead';
-
-=======
->>>>>>> d6d25df3 ([offers][chore] fix import of cities typeahead)
-export default function OffersHomePage() {
- const [jobTitleFilter, setjobTitleFilter] = useState('software-engineer');
- const [companyFilter, setCompanyFilter] = useState('');
- const [cityFilter, setCityFilter] = useState('');
->>>>>>> ac2d047d ([offers][feat] integrate location for offer table and profile)
const { event: gaEvent } = useGoogleAnalytics();
const [selectedCompanyName, setSelectedCompanyName] =
@@ -48,7 +35,6 @@ export default function OffersHomePage() {
. ⭐
-<<<<<<< HEAD
@@ -66,23 +52,6 @@ export default function OffersHomePage() {
});
} else {
setCountryFilter('');
-=======
-
-
-
-
- {
- if (option) {
- setCityFilter(option.value);
- gaEvent({
- action: `offers.table_filter_city_${option.value}`,
- category: 'engagement',
- label: 'Filter by city',
- });
->>>>>>> ac2d047d ([offers][feat] integrate location for offer table and profile)
}
}}
/>
@@ -162,18 +131,12 @@ export default function OffersHomePage() {
>>>>>> ac2d047d ([offers][feat] integrate location for offer table and profile)
/>
);
-}
+}
\ No newline at end of file
diff --git a/apps/portal/src/pages/offers/test/generateAnalysis.tsx b/apps/portal/src/pages/offers/test/generateAnalysis.tsx
deleted file mode 100644
index bf062448..00000000
--- a/apps/portal/src/pages/offers/test/generateAnalysis.tsx
+++ /dev/null
@@ -1,17 +0,0 @@
-import React from 'react';
-
-import { trpc } from '~/utils/trpc';
-
-function GenerateAnalysis() {
- const analysisMutation = trpc.useMutation(['offers.analysis.generate']);
-
- return (
-
- {JSON.stringify(
- analysisMutation.mutate({ profileId: 'cl9lwe9m902k5utskjs52wc0j' }),
- )}
-
- );
-}
-
-export default GenerateAnalysis;
diff --git a/apps/portal/src/pages/offers/test/getAnalysis.tsx b/apps/portal/src/pages/offers/test/getAnalysis.tsx
deleted file mode 100644
index 7d3de61e..00000000
--- a/apps/portal/src/pages/offers/test/getAnalysis.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import React from 'react';
-
-import { trpc } from '~/utils/trpc';
-
-function GetAnalysis() {
- const analysis = trpc.useQuery([
- 'offers.analysis.get',
- { profileId: 'cl9lwe9m902k5utskjs52wc0j' },
- ]);
-
- return {JSON.stringify(analysis.data)}
;
-}
-
-export default GetAnalysis;
diff --git a/apps/portal/src/pages/offers/test/listOffers.tsx b/apps/portal/src/pages/offers/test/listOffers.tsx
deleted file mode 100644
index a06f0957..00000000
--- a/apps/portal/src/pages/offers/test/listOffers.tsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import React from 'react';
-
-import { trpc } from '~/utils/trpc';
-
-function Test() {
- const data = trpc.useQuery([
- 'offers.list',
- {
- currency: 'SGD',
- limit: 100,
- location: 'Singapore, Singapore',
- offset: 0,
- sortBy: '-totalCompensation',
- yoeCategory: 1,
- },
- ]);
-
- const deleteMutation = trpc.useMutation(['offers.profile.delete']);
-
- const handleDelete = (id: string) => {
- deleteMutation.mutate({ profileId: id, token: ' dadaadad' });
- };
-
- return (
-
-
- {JSON.stringify(data.data?.paging)}
-
-
-
- {data.data?.data.map((offer) => {
- return (
-
- {
- handleDelete(offer.profileId);
- }}>
- DELETE THIS PROFILE AND ALL ITS OFFERS
-
- {JSON.stringify(offer)}
-
-
- );
- })}
-
-
-
- );
-}
-
-export default Test;
diff --git a/apps/portal/src/utils/offers/analysisGeneration.ts b/apps/portal/src/utils/offers/analysisGeneration.ts
deleted file mode 100644
index 57da03da..00000000
--- a/apps/portal/src/utils/offers/analysisGeneration.ts
+++ /dev/null
@@ -1,386 +0,0 @@
-import type { Session } from 'next-auth';
-import type {
- City,
- Company,
- Country,
- OffersBackground,
- OffersCurrency,
- OffersFullTime,
- OffersIntern,
- OffersOffer,
- OffersProfile,
- Prisma,
- PrismaClient,
- State,
-} from '@prisma/client';
-import { TRPCError } from '@trpc/server';
-
-import { profileAnalysisDtoMapper } from '../../mappers/offers-mappers';
-
-const searchOfferPercentile = (
- offer: OffersOffer & {
- company: Company;
- offersFullTime:
- | (OffersFullTime & {
- baseSalary: OffersCurrency;
- bonus: OffersCurrency;
- stocks: OffersCurrency;
- totalCompensation: OffersCurrency;
- })
- | null;
- offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null;
- profile: OffersProfile & { background: OffersBackground | null };
- },
- similarOffers: Array<
- OffersOffer & {
- company: Company;
- offersFullTime:
- | (OffersFullTime & {
- totalCompensation: OffersCurrency;
- })
- | null;
- offersIntern: (OffersIntern & { monthlySalary: OffersCurrency }) | null;
- profile: OffersProfile & { background: OffersBackground | null };
- }
- >,
-) => {
- for (let i = 0; i < similarOffers.length; i++) {
- if (similarOffers[i].id === offer.id) {
- return i;
- }
- }
-
- return -1;
-};
-
-export const generateAnalysis = async (params: {
- ctx: {
- prisma: PrismaClient<
- Prisma.PrismaClientOptions,
- never,
- Prisma.RejectOnNotFound | Prisma.RejectPerOperation | undefined
- >;
- session: Session | null;
- };
- input: { profileId: string };
-}) => {
- const { ctx, input } = params;
- await ctx.prisma.offersAnalysis.deleteMany({
- where: {
- profileId: input.profileId,
- },
- });
-
- const offers = await ctx.prisma.offersOffer.findMany({
- include: {
- company: true,
- offersFullTime: {
- include: {
- baseSalary: true,
- bonus: true,
- stocks: true,
- totalCompensation: true,
- },
- },
- offersIntern: {
- include: {
- monthlySalary: true,
- },
- },
- profile: {
- include: {
- background: true,
- },
- },
- },
- orderBy: [
- {
- offersFullTime: {
- totalCompensation: {
- baseValue: 'desc',
- },
- },
- },
- {
- offersIntern: {
- monthlySalary: {
- baseValue: 'desc',
- },
- },
- },
- ],
- where: {
- profileId: input.profileId,
- },
- });
-
- if (!offers || offers.length === 0) {
- throw new TRPCError({
- code: 'NOT_FOUND',
- message: 'No offers found on this profile',
- });
- }
-
- const overallHighestOffer = offers[0];
-
- // TODO: Shift yoe out of background to make it mandatory
- if (
- !overallHighestOffer.profile.background ||
- overallHighestOffer.profile.background.totalYoe == null
- ) {
- throw new TRPCError({
- code: 'NOT_FOUND',
- message: 'YOE not found',
- });
- }
-
- const yoe = overallHighestOffer.profile.background.totalYoe as number;
- const monthYearReceived = new Date(overallHighestOffer.monthYearReceived);
- monthYearReceived.setFullYear(monthYearReceived.getFullYear() - 1);
-
- let similarOffers = await ctx.prisma.offersOffer.findMany({
- include: {
- company: true,
- offersFullTime: {
- include: {
- totalCompensation: true,
- },
- },
- offersIntern: {
- include: {
- monthlySalary: true,
- },
- },
- profile: {
- include: {
- background: {
- include: {
- experiences: {
- include: {
- company: true,
- },
- },
- },
- },
- },
- },
- },
- orderBy: [
- {
- offersFullTime: {
- totalCompensation: {
- baseValue: 'desc',
- },
- },
- },
- {
- offersIntern: {
- monthlySalary: {
- baseValue: 'desc',
- },
- },
- },
- ],
- where: {
- AND: [
- {
- location: overallHighestOffer.location,
- },
- {
- monthYearReceived: {
- gte: monthYearReceived,
- },
- },
- {
- OR: [
- {
- offersFullTime: {
- title: overallHighestOffer.offersFullTime?.title,
- },
- offersIntern: {
- title: overallHighestOffer.offersIntern?.title,
- },
- },
- ],
- },
- {
- profile: {
- background: {
- AND: [
- {
- totalYoe: {
- gte: Math.max(yoe - 1, 0),
- lte: yoe + 1,
- },
- },
- ],
- },
- },
- },
- ],
- },
- });
-
- let similarCompanyOffers = similarOffers.filter(
- (offer) => offer.companyId === overallHighestOffer.companyId,
- );
-
- // CALCULATE PERCENTILES
- const overallIndex = searchOfferPercentile(
- overallHighestOffer,
- similarOffers,
- );
- const overallPercentile =
- similarOffers.length === 0
- ? 100
- : (100 * overallIndex) / similarOffers.length;
-
- const companyIndex = searchOfferPercentile(
- overallHighestOffer,
- similarCompanyOffers,
- );
- const companyPercentile =
- similarCompanyOffers.length === 0
- ? 100
- : (100 * companyIndex) / similarCompanyOffers.length;
-
- // FIND TOP >=90 PERCENTILE OFFERS, DOESN'T GIVE 100th PERCENTILE
- // e.g. If there only 4 offers, it gives the 2nd and 3rd offer
- similarOffers = similarOffers.filter(
- (offer) => offer.id !== overallHighestOffer.id,
- );
- similarCompanyOffers = similarCompanyOffers.filter(
- (offer) => offer.id !== overallHighestOffer.id,
- );
-
- const noOfSimilarOffers = similarOffers.length;
- const similarOffers90PercentileIndex = Math.ceil(noOfSimilarOffers * 0.1);
- const topPercentileOffers =
- noOfSimilarOffers > 2
- ? similarOffers.slice(
- similarOffers90PercentileIndex,
- similarOffers90PercentileIndex + 2,
- )
- : similarOffers;
-
- const noOfSimilarCompanyOffers = similarCompanyOffers.length;
- const similarCompanyOffers90PercentileIndex = Math.ceil(
- noOfSimilarCompanyOffers * 0.1,
- );
- const topPercentileCompanyOffers =
- noOfSimilarCompanyOffers > 2
- ? similarCompanyOffers.slice(
- similarCompanyOffers90PercentileIndex,
- similarCompanyOffers90PercentileIndex + 2,
- )
- : similarCompanyOffers;
-
- const analysis = await ctx.prisma.offersAnalysis.create({
- data: {
- companyPercentile,
- noOfSimilarCompanyOffers,
- noOfSimilarOffers,
- overallHighestOffer: {
- connect: {
- id: overallHighestOffer.id,
- },
- },
- overallPercentile,
- profile: {
- connect: {
- id: input.profileId,
- },
- },
- topCompanyOffers: {
- connect: topPercentileCompanyOffers.map((offer) => {
- return { id: offer.id };
- }),
- },
- topOverallOffers: {
- connect: topPercentileOffers.map((offer) => {
- return { id: offer.id };
- }),
- },
- },
- include: {
- overallHighestOffer: {
- include: {
- company: true,
- offersFullTime: {
- include: {
- totalCompensation: true,
- },
- },
- offersIntern: {
- include: {
- monthlySalary: true,
- },
- },
- profile: {
- include: {
- background: true,
- },
- },
- },
- },
- topCompanyOffers: {
- include: {
- company: true,
- offersFullTime: {
- include: {
- totalCompensation: true,
- },
- },
- offersIntern: {
- include: {
- monthlySalary: true,
- },
- },
- profile: {
- include: {
- background: {
- include: {
- experiences: {
- include: {
- company: true,
- },
- },
- },
- },
- },
- },
- },
- },
- topOverallOffers: {
- include: {
- company: true,
- offersFullTime: {
- include: {
- totalCompensation: true,
- },
- },
- offersIntern: {
- include: {
- monthlySalary: true,
- },
- },
- profile: {
- include: {
- background: {
- include: {
- experiences: {
- include: {
- company: true,
- },
- },
- },
- },
- },
- },
- },
- },
- },
- });
-
- return profileAnalysisDtoMapper(analysis);
-};