Skip to content

Commit

Permalink
Merge branch 'ads-debug-mode'
Browse files Browse the repository at this point in the history
  • Loading branch information
nissamai committed Apr 12, 2022
2 parents 4ccea77 + b12172b commit fe7622f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
16 changes: 14 additions & 2 deletions static/js/Promotions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const Promotions = ({adType, rerender}) => {
const url =
'https://docs.google.com/spreadsheets/d/1UJw2Akyv3lbLqBoZaFVWhaAp-FUQ-YZfhprL_iNhhQc/edit#gid=0'
const query = new google.visualization.Query(url);
query.setQuery('select A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P');
query.setQuery('select A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q');
query.send(processSheetsData);
}

Expand All @@ -52,13 +52,24 @@ const Promotions = ({adType, rerender}) => {
return false;
}
}

function showGivenDebugMode(ad) {
if (!ad.debug) {
return true;
} else if (context.isDebug == true) {
return true;
} else {
return false
}
}


function getCurrentMatchingAds() {
// TODO: refine matching algorithm to order by matchingness?
return inAppAds.filter(ad => {
return (
showToUser(ad) &&
showGivenDebugMode(ad) &&
ad.trigger.interfaceLang === context.interfaceLang &&
ad.adType === adType &&
context.dt > ad.trigger.dt_start && context.dt < ad.trigger.dt_end &&
Expand Down Expand Up @@ -108,7 +119,8 @@ const Promotions = ({adType, rerender}) => {
dt_end: Date.parse(row[2]),
keywordTargets: keywordTargetsArray,
excludeKeywordTargets: excludeKeywordTargets
}
},
debug: parseInt(row[16])
}
)
}
Expand Down
1 change: 1 addition & 0 deletions static/js/ReaderApp.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -1810,6 +1810,7 @@ class ReaderApp extends Component {
.filter(ref => !!ref);
const deDupedTriggers = [...new Set(triggers.map(JSON.stringify))].map(JSON.parse);
const context = {
isDebug: this.props._debug,
isLoggedIn: Sefaria._uid,
interfaceLang: Sefaria.interfaceLang,
dt: Sefaria.util.epoch_time(new Date())*1000,
Expand Down

0 comments on commit fe7622f

Please sign in to comment.