Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
feat: Add totals to sponsors data file (#920)
Browse files Browse the repository at this point in the history
* feat: Add totals to sponsors data file

* Update homepage with stored data
  • Loading branch information
nzakas authored Feb 4, 2022
1 parent 5aa1575 commit cf4e211
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 14 deletions.
13 changes: 13 additions & 0 deletions _data/sponsors.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"totals": {
"annualDonations": 147409.07999999996,
"monthlyDonations": 12284.09,
"sponsorCount": 178
},
"platinum": [
{
"name": "Automattic",
Expand Down Expand Up @@ -1235,6 +1240,14 @@
"source": "github",
"tier": "backer"
},
{
"name": "Sebastian Silbermann",
"image": "https://avatars.githubusercontent.com/u/12292047?u=b680d2aedb93269d597e78306e6e136c8ebaf328&v=4",
"url": "https://solverfox.dev",
"monthlyDonation": 500,
"source": "github",
"tier": "backer"
},
{
"name": "Michael Rotarius",
"image": "https://avatars.githubusercontent.com/u/13236924?u=c07053c05ab6ed3abd3a11a303186219b60c8adf&v=4",
Expand Down
14 changes: 1 addition & 13 deletions _pages/index.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -21,23 +21,11 @@ homepage: true
</div>

<hr class="hr-near-below">
{% assign tiers = "platinum,gold,silver,bronze,backers" | split: "," %}
{% assign monthlyTotal = 0 %}
{% assign supportersCount = 0 %}
{% for tier in tiers %}
{% if sponsors[tier].size > 0 %}
{% for sponsor in sponsors[tier] %}
{% assign supportersCount = supportersCount | plus: 1 %}
{% assign monthlyTotal = monthlyTotal | plus: sponsor.monthlyDonation %}
{% endfor %}
{% endif %}
{% endfor %}
{% assign monthlyTotal = monthlyTotal | divided_by: 100 %}

<div class="sponsors row">
<div class="col-sm-12">
<h2 class="text-center">Sponsors</h2>
<p class="sponsor-desc text-center">{{ supportersCount }} companies, organizations, and individuals are currently contributing <b>${{ monthlyTotal }}</b> each month to support ESLint's ongoing maintenance and development.</p>
<p class="sponsor-desc text-center">{{ sponsors.totals.sponsorCount }} companies, organizations, and individuals are currently contributing <b>${{ sponsors.totals.monthlyDonations }}</b> each month to support ESLint's ongoing maintenance and development.</p>
<p class="sponsor-btn text-center"><a class="btn btn-default" href="https://opencollective.com/eslint">Become a Sponsor today!</a></p>
<div class="sponsor-tiers">
{% assign tiers = "platinum,gold,silver,bronze" | split: "," %}
Expand Down
18 changes: 17 additions & 1 deletion _tools/fetch-sponsors.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,10 @@ const tierSponsors = {
backers: []
};

let annualDonations = 0;
let monthlyDonations = 0;
let sponsorCount = 0;

const { ESLINT_GITHUB_TOKEN } = process.env;

if (!ESLINT_GITHUB_TOKEN) {
Expand Down Expand Up @@ -187,6 +191,11 @@ async function fetchGitHubSponsors() {
// process into a useful format
for (const sponsor of sponsors) {

// calculate totals
sponsorCount++;
annualDonations += sponsor.monthlyDonation / 100 * 12;
monthlyDonations += sponsor.monthlyDonation / 100;

switch (sponsor.tier) {
case "platinum-sponsor":
tierSponsors.platinum.push(sponsor);
Expand Down Expand Up @@ -215,5 +224,12 @@ async function fetchGitHubSponsors() {
tierSponsors[key].sort((a, b) => b.monthlyDonation - a.monthlyDonation);
}

fs.writeFileSync(sponsorsFilename, JSON.stringify(tierSponsors, null, " "), { encoding: "utf8" });
fs.writeFileSync(sponsorsFilename, JSON.stringify({
totals: {
annualDonations,
monthlyDonations,
sponsorCount
},
...tierSponsors
}, null, " "), { encoding: "utf8" });
})();

0 comments on commit cf4e211

Please sign in to comment.