Skip to content

Commit

Permalink
Fixed sponsors' tiers resolving (#196)
Browse files Browse the repository at this point in the history
* feat: add sponsor list generator;

* feat: added deploy action;

* fix: fixed layout;

* fix: use utm links inside tooltips;

* fix(CI): set engine version;

* chore: reverted the start button title change;

* fix: add the ability to retry the request to get a list of sponsors;

* chore: change sponsors config & fix sponsor card layout;

* chore: hide 'incognito' sponsor from the list of sponsors;

* chore: add Route4Me sponsor;

* chore: fixed resolution of utm link for manually added sponsors;

* chore: fixed sponsors' tiers resolving;
  • Loading branch information
DigitalBrainJS committed Aug 1, 2024
1 parent ff09c54 commit b343a4b
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 4 deletions.
18 changes: 16 additions & 2 deletions data/sponsors.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,32 @@
"scoreTierPriceFactor": 0.70,
"scoreTotalAmountFactor": 0.2,
"tiers": {
"$49 a month": {
"bronze": {
"price": 49,
"benefits": {
"showAtSponsorList": true
}
},
"$99 a month" : {
"silver" : {
"price": 99,
"benefits": {
"showAtSponsorList": true,
"showAtPages": true
}
},
"gold" : {
"price": 299,
"benefits": {
"showAtSponsorList": true,
"showAtPages": true
}
},
"platinum" : {
"price": 599,
"benefits": {
"showAtSponsorList": true,
"showAtPages": true
}
}
},
"sponsors": {
Expand Down
15 changes: 13 additions & 2 deletions scripts/updateData.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,11 +273,12 @@ const processSponsors = async (sponsorsData, sponsorsConfig = './data/sponsors.j
const averageMonthlyContribution = sponsor.totalAmountDonated / (monthsPassed || 1);

const {isActive} = sponsor;
const tier = isActive && sponsor.tier;
const hasActiveTier = tier && tier !== 'Backer';
const tier = isActive && String(sponsor.tier || '').toLowerCase();
const hasActiveTier = !!(tier && tier !== 'backer');
const {price = 0, benefits = null} = tier && tiers[tier] || {};

sponsor.benefits = {
// backers without active tier
showAtSponsorList: sponsor.totalAmountDonated >= totalAmountDonatedThreshold && averageMonthlyContribution >= monthlyContributionThreshold,
...benefits
};
Expand All @@ -288,6 +289,16 @@ const processSponsors = async (sponsorsData, sponsorsConfig = './data/sponsors.j
opacity: hasActiveTier ? 1 : Math.max(0.5, Math.min(1, creditLeft / disappearCredit)).toFixed(1)
}

console.log(
`Add sponsor badge [${sponsor.displayName}]
- tier: ${tier ? tier + '(' + price + '$)' : '< none >'}
- total amount donated: ${sponsor.totalAmountDonated}$
- website: ${sponsor.website}
- credit left: ${creditLeft}$
- has active tier: ${hasActiveTier}
- showAtSponsorList: ${sponsor.benefits.showAtSponsorList}
`);

return {
...sponsor,
averageMonthlyContribution: Math.round(averageMonthlyContribution),
Expand Down

0 comments on commit b343a4b

Please sign in to comment.