diff --git a/tools/fetch-sponsors.js b/tools/fetch-sponsors.js index 16d075150..d892eb215 100644 --- a/tools/fetch-sponsors.js +++ b/tools/fetch-sponsors.js @@ -74,16 +74,7 @@ function getTierSlug(monthlyDonation) { async function fetchOpenCollectiveData() { const endpoint = "https://api.opencollective.com/graphql/v2"; - const now = new Date(); - const startOfCurrentMonth = `${now.getFullYear()}-${(now.getMonth()+1).toString().padStart(2, "0")}-01T00:00:00Z`; - - /* - * account.orders - These are the currently active sponsorships. - * account.cancelledOrders - These are the sponsorships that are still - * active for this month but have been cancelled. OC doesn't include - * these as status: ACTIVE so we need to do a separate query to - * retrieve them. - */ + const query = `{ account(slug: "eslint") { orders(status: ACTIVE, filter: INCOMING) { @@ -106,29 +97,7 @@ async function fetchOpenCollectiveData() { } } } - - cancelledOrders: orders(status: CANCELLED, filter: INCOMING, onlySubscriptions: true, dateFrom:"${startOfCurrentMonth}") { - totalCount - nodes { - fromAccount { - name - website - imageUrl - } - amount { - value - } - tier { - slug - } - frequency - totalDonations { - value - } - } - } } - donations: orders( account: { slug: "eslint" } frequency: ONETIME @@ -162,9 +131,7 @@ async function fetchOpenCollectiveData() { let payload = await result.json(); - const sponsors = payload.data.account.orders.nodes.concat( - payload.data.account.cancelledOrders.nodes - ).map(order => ({ + const sponsors = payload.data.account.orders.nodes.map(order => ({ name: order.fromAccount.name, url: order.fromAccount.website, image: order.fromAccount.imageUrl, @@ -319,6 +286,7 @@ async function fetchGitHubSponsors() { const sponsors = openCollectiveSponsors.concat(githubSponsors); const donations = openCollectiveDonations.concat(githubDonations); + // sort donations so most recent is first donations.sort((a, b) => new Date(a) - new Date(b));