BETTERZON-150: Fixing best deals API endpoint logic (#92)

This commit is contained in:
Patrick 2021-06-16 09:20:40 +02:00 committed by GitHub
parent c90949de47
commit 841502f9d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -282,11 +282,11 @@ export const getBestDeals = async (amount: number): Promise<Prices> => {
'price_in_cents': lowestPrice.price_in_cents, 'price_in_cents': lowestPrice.price_in_cents,
'timestamp': lowestPrice.timestamp, 'timestamp': lowestPrice.timestamp,
'amazonDifference': (amazonPrice.price_in_cents - lowestPrice.price_in_cents), 'amazonDifference': (amazonPrice.price_in_cents - lowestPrice.price_in_cents),
'amazonDifferencePercent': ((1 - (lowestPrice.price_in_cents / amazonPrice.price_in_cents)) * 100), 'amazonDifferencePercent': ((amazonPrice.price_in_cents / lowestPrice.price_in_cents) * 100),
}; };
// Push only deals were the amazon price is actually higher // Push only deals were the amazon price is actually higher
if (deal.amazonDifferencePercent > 0) { if (deal.amazonDifferencePercent > 0 && deal.amazonDifference > 0) {
deals.push(deal as Deal); deals.push(deal as Deal);
} }
} }