Skip to content
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

fix: Ensure donations don't show up as sponsors #623

Merged
merged 2 commits into from
Sep 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions tools/fetch-sponsors.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ const knownOneTimers = new Set([
"GitHub Sponsors",
"Read the Docs",
"BuySellAds",
"EthicalAds",
"Threadless",
]);

// we must have a token for this to work
Expand Down Expand Up @@ -223,6 +225,7 @@ async function fetchGitHubSponsors() {
},
tier {
monthlyPriceInDollars
isOneTime
}
}
pageInfo {
Expand Down Expand Up @@ -329,16 +332,23 @@ async function fetchGitHubSponsors() {
);
}

// return an array in the same format as Open Collective
const sponsors = sponsorships.map(({ sponsor, tier }) => ({
name: sponsor.name || sponsor.login,
image: sponsor.avatarUrl,
url: fixUrl(sponsor.websiteUrl || sponsor.url),
monthlyDonation: tier.monthlyPriceInDollars,
source: "github",
tier: getTierSlug(tier.monthlyPriceInDollars),
}));
// process sponsorships
const sponsors = sponsorships

// filter out one-time sponsorships -- these are displayed in the donations list
.filter(({ tier }) => !tier.isOneTime)

// return an array in the same format as Open Collective
.map(({ sponsor, tier }) => ({
name: sponsor.name || sponsor.login,
image: sponsor.avatarUrl,
url: fixUrl(sponsor.websiteUrl || sponsor.url),
monthlyDonation: tier.monthlyPriceInDollars,
source: "github",
tier: getTierSlug(tier.monthlyPriceInDollars),
}));

// process one-time donations
const donations = donationsResponse.organization.sponsorsActivities.nodes
.filter(transaction => transaction.tier && transaction.tier.isOneTime)
.map(({ sponsor, timestamp, tier, id }) => ({
Expand Down Expand Up @@ -387,7 +397,7 @@ async function fetchGitHubSponsors() {
const donations = openCollectiveDonations.concat(githubDonations);

// sort donations so most recent is first
donations.sort((a, b) => new Date(a) - new Date(b));
donations.sort((a, b) => Date.parse(b.date) - Date.parse(a.date));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!


// simplified data structure
const tierSponsors = {
Expand Down
Loading