mirror of
https://github.com/Mueller-Patrick/Betterzon.git
synced 2024-11-22 06:13:57 +00:00
BETTERZON-150: Fixing best deals API endpoint logic (#92)
This commit is contained in:
parent
c90949de47
commit
841502f9d1
|
@ -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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user