FIX: add a fix for cases where ad record is not found (#214)

This commit is contained in:
Arpit Jalan 2024-07-05 13:00:18 +05:30 committed by GitHub
parent 9b72130fdf
commit ec53a0d6b8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 6 additions and 4 deletions

View File

@ -76,8 +76,9 @@ export default AdComponent.extend({
const filteredAds = adNames.filter((adName) => {
const ad = houseAds.creatives[adName];
return (
!ad.category_ids?.length ||
ad.category_ids.includes(this.currentCategoryId)
ad &&
(!ad.category_ids?.length ||
ad.category_ids.includes(this.currentCategoryId))
);
});
if (filteredAds.length > 0) {
@ -129,8 +130,9 @@ export default AdComponent.extend({
const filteredAds = adNames.filter((adName) => {
const ad = houseAds.creatives[adName];
return (
!ad.category_ids?.length ||
ad.category_ids.includes(this.currentCategoryId)
ad &&
(!ad.category_ids?.length ||
ad.category_ids.includes(this.currentCategoryId))
);
});
adIndex[placement] = Math.floor(Math.random() * filteredAds.length);