-
Notifications
You must be signed in to change notification settings - Fork 158
fix(sponsors): respect hide config for the Readme.md sponsor list generator; #243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4bc8290
ee08fd7
41f9e16
40786a2
40d1a3e
19c8502
fff1739
e3dab01
7b6a7ee
c422c0f
0cacb8d
7e5ea9d
9c095a1
994feea
1de0ae2
e2a8980
5d596d7
eb40933
fc788d6
1323284
2b25c52
e04de97
0581c93
257ca85
e271d28
485a129
88b391c
7cdfde9
7e1677a
142c72a
f60ee95
383f9e9
50cf187
3002a68
29354f9
1078438
a369593
cffcb2e
d0f2b6c
b508733
410237d
86b8d06
106f263
081b280
7c75d3d
f043be0
c94d98b
0723dd8
9ddc201
3b88169
34728f8
fc56bc9
a532b98
2c65f76
37b9cf0
d9a4467
60477f5
ebe93cc
23c056d
e4b2cf6
61949a0
2bf5d48
f74bd42
2ce9e0a
71e851d
34e96b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -356,6 +356,7 @@ const renderMarkdownSponsors = async (sponsors) => { | |||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
const filterSponsors = (fn) => Object.values(sponsors) | ||||||||||||||||||
.filter(({hide}) => !hide) | ||||||||||||||||||
.filter(fn) | ||||||||||||||||||
.sort((a, b) => new Date(a.createdAt) - new Date(b.createdAt)); | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -517,14 +518,15 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon | |||||||||||||||||
tiers, | ||||||||||||||||||
scoreTierPriceFactor = 0.5, | ||||||||||||||||||
scoreTotalAmountFactor = 0.2, | ||||||||||||||||||
creditDays = 0 | ||||||||||||||||||
creditDays = 0, | ||||||||||||||||||
hide = {} | ||||||||||||||||||
} = await readJSON(sponsorsConfig) || {}; | ||||||||||||||||||
|
||||||||||||||||||
const mergedSponsors = {}; | ||||||||||||||||||
|
||||||||||||||||||
// merge Open Collective sponsors | ||||||||||||||||||
collectiveSponsors.forEach(sponsor => { | ||||||||||||||||||
if (sponsor.role !== 'BACKER' && sponsor.role) { | ||||||||||||||||||
if ((sponsor.role !== 'BACKER' && sponsor.role) || hide[sponsor.login?.toLowerCase()] || hide[sponsor.name?.toLowerCase()]) { | ||||||||||||||||||
return; | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
|
@@ -572,6 +574,12 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon | |||||||||||||||||
|
||||||||||||||||||
if (lastTransactionAmount) { | ||||||||||||||||||
sponsor.tier = findTier(lastTransactionAmount, sponsorTiers); | ||||||||||||||||||
|
||||||||||||||||||
let partiallyPaid = findTier(lastTransactionAmount * 1.1, sponsorTiers); | ||||||||||||||||||
|
||||||||||||||||||
if (sponsor.tier !== partiallyPaid) { | ||||||||||||||||||
sponsor.tier = partiallyPaid; | ||||||||||||||||||
} | ||||||||||||||||||
Comment on lines
576
to
+582
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. [nitpick] The sponsor tier is reassigned using the partiallyPaid value immediately after initial assignment; consolidating the tier determination logic could help avoid potential inconsistencies.
Suggested change
Copilot is powered by AI, so mistakes are possible. Review output carefully before use. Positive FeedbackNegative Feedback |
||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
const tierId = sponsor.tier ? sponsor.tier?.toLowerCase() : null; | ||||||||||||||||||
|
@@ -581,7 +589,17 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon | |||||||||||||||||
console.log(`Unknown tier [${sponsor.tier}]`); | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
const {price, benefits, period = PERIOD} = tierData || {}; | ||||||||||||||||||
let {price, benefits, period = PERIOD, credit = 3} = tierData || {}; | ||||||||||||||||||
|
||||||||||||||||||
let shortageFactor = price && lastTransactionAmount < price ? lastTransactionAmount / price * 0.9 : 1; | ||||||||||||||||||
|
||||||||||||||||||
period = period * shortageFactor; | ||||||||||||||||||
|
||||||||||||||||||
sponsor.isNew = !!(sponsor.createdAt && days(sponsor.createdAt) < 7); | ||||||||||||||||||
|
||||||||||||||||||
sponsor.credit ??= credit || 0; | ||||||||||||||||||
|
||||||||||||||||||
period += sponsor.credit; | ||||||||||||||||||
|
||||||||||||||||||
if (sponsor.isActive == null) { | ||||||||||||||||||
sponsor.isActive = tierData && days(lastTransactionAt) <= period && sponsor.lastTransactionAmount >= price; | ||||||||||||||||||
|
@@ -593,8 +611,8 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon | |||||||||||||||||
|
||||||||||||||||||
const isCustomTier = !!(tierData && price !== originalTierPrice); | ||||||||||||||||||
sponsor.tierId = tierId; | ||||||||||||||||||
sponsor.tier = sponsor.tier + (lastTransactionAmount > originalTierPrice ? '+' : '') | ||||||||||||||||||
sponsor.tierPrice = price; | ||||||||||||||||||
sponsor.tier = sponsor.tier ? sponsor.tier + (lastTransactionAmount > originalTierPrice ? '+' : '') : null; | ||||||||||||||||||
sponsor.tierPrice = price || 0; | ||||||||||||||||||
sponsor.originalTierPrice = originalTierPrice; | ||||||||||||||||||
sponsor.isCustomTier = isCustomTier; | ||||||||||||||||||
sponsor.totalAmountDonated = sponsor.totalAmountDonated || lastTransactionAmount || 0; | ||||||||||||||||||
|
@@ -677,10 +695,19 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon | |||||||||||||||||
opacity: timeLeft == null || timeLeft > 0 ? 1 :(sponsor.timeLeft / (creditDays * DAY)) | ||||||||||||||||||
} | ||||||||||||||||||
|
||||||||||||||||||
const score = Math.round( | ||||||||||||||||||
sponsor.totalAmountDonated * scoreTotalAmountFactor + | ||||||||||||||||||
averageMonthlyContribution + | ||||||||||||||||||
tierPrice * scoreTierPriceFactor | ||||||||||||||||||
); | ||||||||||||||||||
|
||||||||||||||||||
console.log( | ||||||||||||||||||
`Add sponsor badge [${sponsor.displayName}] | ||||||||||||||||||
- tier: ${tier ? tier + '(' + tierPrice + '$)' : '< none >'} | ||||||||||||||||||
- score : ${score} | ||||||||||||||||||
- tier: ${tier || '< null >'} | ||||||||||||||||||
- tier price: ${tierPrice} | ||||||||||||||||||
- total amount donated: ${sponsor.totalAmountDonated}$ | ||||||||||||||||||
- averageMonthlyContribution: ${averageMonthlyContribution} | ||||||||||||||||||
- last donation date: ${sponsor.lastTransactionAt} | ||||||||||||||||||
- created: ${sponsor.createdAt} | ||||||||||||||||||
- target link: ${sponsor.targetLink} | ||||||||||||||||||
|
@@ -693,7 +720,7 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon | |||||||||||||||||
return { | ||||||||||||||||||
...sponsor, | ||||||||||||||||||
averageMonthlyContribution, | ||||||||||||||||||
score: Math.round(sponsor.totalAmountDonated * scoreTotalAmountFactor + averageMonthlyContribution + tierPrice * scoreTierPriceFactor) | ||||||||||||||||||
score | ||||||||||||||||||
}; | ||||||||||||||||||
}) | ||||||||||||||||||
.sort((a, b) => b.score - a.score) | ||||||||||||||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -357,7 +357,7 @@ | |
|
||
setTimeout(() => { | ||
splide.Components.AutoScroll.play(); | ||
}, 3000); | ||
}, 5000); | ||
} | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] Consider extracting the hide check into a separate variable (e.g., isHidden) to improve clarity and reduce the potential for errors in this complex conditional.
Copilot is powered by AI, so mistakes are possible. Review output carefully before use.