Skip to content

Commit

Permalink
chore: Revert OC sponsors fetch changes (#465)
Browse files Browse the repository at this point in the history
* Revert "fix: OC sponsors fetch for cancelled orders (#455)"

This reverts commit 0066b21.

* Revert "fix: Include cancelled sponsorships"

This reverts commit 410b7ae.
  • Loading branch information
nzakas authored Aug 4, 2023
1 parent 786024e commit 09d5fc4
Showing 1 changed file with 3 additions and 35 deletions.
38 changes: 3 additions & 35 deletions tools/fetch-sponsors.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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));

Expand Down

0 comments on commit 09d5fc4

Please sign in to comment.