Skip to content

Commit

Permalink
fix: only use offers with a discount of 100% in the epic api scraper
Browse files Browse the repository at this point in the history
Signed-off-by: Eiko Wagenknecht <[email protected]>
  • Loading branch information
eikowagenknecht committed Feb 10, 2025
1 parent 5509659 commit b0e9dde
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions src/services/scraper/implementations/epicApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -229,15 +229,29 @@ export class EpicGamesApiScraper extends BaseScraper {
}

private getPromotionalDates(offer: RawOffer) {
if (!offer.promotions?.promotionalOffers?.[0]?.promotionalOffers?.[0]) {
return { startDate: null, endDate: null };
const res: { startDate: string | null; endDate: string | null } = {
startDate: null,
endDate: null,
};

if (!offer.promotions?.promotionalOffers) {
return res;
}

const promo = offer.promotions.promotionalOffers[0].promotionalOffers[0];
return {
startDate: promo.startDate,
endDate: promo.endDate,
};
for (const promo of offer.promotions.promotionalOffers) {
for (const subPromo of promo.promotionalOffers) {
if (
subPromo.startDate &&
subPromo.endDate &&
subPromo.discountSetting.discountPercentage === 0
) {
res.startDate = subPromo.startDate;
res.endDate = subPromo.endDate;
}
}
}

return res;
}

private getMainImage(offer: RawOffer): string {
Expand Down

0 comments on commit b0e9dde

Please sign in to comment.