From a421a0d98a9440a2a707fc4c191afb52a34302f0 Mon Sep 17 00:00:00 2001 From: Bryann Yeap Kok Keong Date: Mon, 7 Nov 2022 03:12:44 +0800 Subject: [PATCH] [offers][fix] Fix analysis bug that causes percentile to go negative --- apps/portal/src/utils/offers/analysis/analysisGeneration.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/portal/src/utils/offers/analysis/analysisGeneration.ts b/apps/portal/src/utils/offers/analysis/analysisGeneration.ts index 956de901..fad35434 100644 --- a/apps/portal/src/utils/offers/analysis/analysisGeneration.ts +++ b/apps/portal/src/utils/offers/analysis/analysisGeneration.ts @@ -199,7 +199,7 @@ const calculatePercentile = ( const salary = getSalary(offer, lastOfferSalary); if (salary !== lastOfferSalary) { - if (salary === offerToCalculateSalary) { + if (salary === offerToCalculateSalary && offerToCalculateIndex === -1) { offerToCalculateIndex = i; } numberOfNoDuplicateOffers++;