@@ -356,6 +356,7 @@ const renderMarkdownSponsors = async (sponsors) => {
356356 }
357357
358358 const filterSponsors = ( fn ) => Object . values ( sponsors )
359+ . filter ( ( { hide} ) => ! hide )
359360 . filter ( fn )
360361 . sort ( ( a , b ) => new Date ( a . createdAt ) - new Date ( b . createdAt ) ) ;
361362
@@ -517,14 +518,15 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
517518 tiers,
518519 scoreTierPriceFactor = 0.5 ,
519520 scoreTotalAmountFactor = 0.2 ,
520- creditDays = 0
521+ creditDays = 0 ,
522+ hide = { }
521523 } = await readJSON ( sponsorsConfig ) || { } ;
522524
523525 const mergedSponsors = { } ;
524526
525527 // merge Open Collective sponsors
526528 collectiveSponsors . forEach ( sponsor => {
527- if ( sponsor . role !== 'BACKER' && sponsor . role ) {
529+ if ( ( sponsor . role !== 'BACKER' && sponsor . role ) || hide [ sponsor . login ?. toLowerCase ( ) ] || hide [ sponsor . name ?. toLowerCase ( ) ] ) {
528530 return ;
529531 }
530532
@@ -572,6 +574,12 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
572574
573575 if ( lastTransactionAmount ) {
574576 sponsor . tier = findTier ( lastTransactionAmount , sponsorTiers ) ;
577+
578+ let partiallyPaid = findTier ( lastTransactionAmount * 1.1 , sponsorTiers ) ;
579+
580+ if ( sponsor . tier !== partiallyPaid ) {
581+ sponsor . tier = partiallyPaid ;
582+ }
575583 }
576584
577585 const tierId = sponsor . tier ? sponsor . tier ?. toLowerCase ( ) : null ;
@@ -581,7 +589,17 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
581589 console . log ( `Unknown tier [${ sponsor . tier } ]` ) ;
582590 }
583591
584- const { price, benefits, period = PERIOD } = tierData || { } ;
592+ let { price, benefits, period = PERIOD , credit = 3 } = tierData || { } ;
593+
594+ let shortageFactor = price && lastTransactionAmount < price ? lastTransactionAmount / price * 0.9 : 1 ;
595+
596+ period = period * shortageFactor ;
597+
598+ sponsor . isNew = ! ! ( sponsor . createdAt && days ( sponsor . createdAt ) < 7 ) ;
599+
600+ sponsor . credit ??= credit || 0 ;
601+
602+ period += sponsor . credit ;
585603
586604 if ( sponsor . isActive == null ) {
587605 sponsor . isActive = tierData && days ( lastTransactionAt ) <= period && sponsor . lastTransactionAmount >= price ;
@@ -593,8 +611,8 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
593611
594612 const isCustomTier = ! ! ( tierData && price !== originalTierPrice ) ;
595613 sponsor . tierId = tierId ;
596- sponsor . tier = sponsor . tier + ( lastTransactionAmount > originalTierPrice ? '+' : '' )
597- sponsor . tierPrice = price ;
614+ sponsor . tier = sponsor . tier ? sponsor . tier + ( lastTransactionAmount > originalTierPrice ? '+' : '' ) : null ;
615+ sponsor . tierPrice = price || 0 ;
598616 sponsor . originalTierPrice = originalTierPrice ;
599617 sponsor . isCustomTier = isCustomTier ;
600618 sponsor . totalAmountDonated = sponsor . totalAmountDonated || lastTransactionAmount || 0 ;
@@ -677,10 +695,19 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
677695 opacity : timeLeft == null || timeLeft > 0 ? 1 :( sponsor . timeLeft / ( creditDays * DAY ) )
678696 }
679697
698+ const score = Math . round (
699+ sponsor . totalAmountDonated * scoreTotalAmountFactor +
700+ averageMonthlyContribution +
701+ tierPrice * scoreTierPriceFactor
702+ ) ;
703+
680704 console . log (
681705 `Add sponsor badge [${ sponsor . displayName } ]
682- - tier: ${ tier ? tier + '(' + tierPrice + '$)' : '< none >' }
706+ - score : ${ score }
707+ - tier: ${ tier || '< null >' }
708+ - tier price: ${ tierPrice }
683709 - total amount donated: ${ sponsor . totalAmountDonated } $
710+ - averageMonthlyContribution: ${ averageMonthlyContribution }
684711 - last donation date: ${ sponsor . lastTransactionAt }
685712 - created: ${ sponsor . createdAt }
686713 - target link: ${ sponsor . targetLink }
@@ -693,7 +720,7 @@ const processSponsors = async (collectiveSponsors, sponsorsConfig = './data/spon
693720 return {
694721 ...sponsor ,
695722 averageMonthlyContribution,
696- score : Math . round ( sponsor . totalAmountDonated * scoreTotalAmountFactor + averageMonthlyContribution + tierPrice * scoreTierPriceFactor )
723+ score
697724 } ;
698725 } )
699726 . sort ( ( a , b ) => b . score - a . score )
0 commit comments