From 09d5fc4ecd78807e8951e7018ec1879ce63b02de Mon Sep 17 00:00:00 2001 From: "Nicholas C. Zakas" Date: Fri, 4 Aug 2023 17:26:34 -0400 Subject: [PATCH] chore: Revert OC sponsors fetch changes (#465) * Revert "fix: OC sponsors fetch for cancelled orders (#455)" This reverts commit 0066b21bb80a207db2836b2eb59826acf79a8702. * Revert "fix: Include cancelled sponsorships" This reverts commit 410b7ae925044668013170140242997512e32441. --- tools/fetch-sponsors.js | 38 +++----------------------------------- 1 file changed, 3 insertions(+), 35 deletions(-) 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));