mirror of
https://github.com/yangshun/tech-interview-handbook.git
synced 2026-04-02 18:38:22 +08:00
[offers][chore] Add monthYearReceived to the analysis generation API
This commit is contained in:
@@ -225,6 +225,8 @@ export const offersAnalysisRouter = createRouter()
|
||||
}
|
||||
|
||||
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: {
|
||||
@@ -274,6 +276,11 @@ export const offersAnalysisRouter = createRouter()
|
||||
{
|
||||
location: overallHighestOffer.location,
|
||||
},
|
||||
{
|
||||
monthYearReceived: {
|
||||
gte: monthYearReceived,
|
||||
},
|
||||
},
|
||||
{
|
||||
OR: [
|
||||
{
|
||||
@@ -315,7 +322,9 @@ export const offersAnalysisRouter = createRouter()
|
||||
similarOffers,
|
||||
);
|
||||
const overallPercentile =
|
||||
similarOffers.length === 0 ? 1.0 : overallIndex / similarOffers.length;
|
||||
similarOffers.length === 0
|
||||
? 100
|
||||
: (100 * overallIndex) / similarOffers.length;
|
||||
|
||||
const companyIndex = searchOfferPercentile(
|
||||
overallHighestOffer,
|
||||
@@ -323,8 +332,8 @@ export const offersAnalysisRouter = createRouter()
|
||||
);
|
||||
const companyPercentile =
|
||||
similarCompanyOffers.length === 0
|
||||
? 1.0
|
||||
: companyIndex / similarCompanyOffers.length;
|
||||
? 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
|
||||
|
||||
Reference in New Issue
Block a user