Skip to content

Commit

Permalink
Use a better overall query
Browse files Browse the repository at this point in the history
  • Loading branch information
rfay committed Nov 9, 2024
1 parent d9477dc commit 10db4b5
Showing 1 changed file with 6 additions and 27 deletions.
33 changes: 6 additions & 27 deletions src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,64 +85,43 @@ export async function getSponsors() {
}

const response = await octokit().graphql(`
query {
user(login: "rfay") {
... on Sponsorable {
query CombinedSponsors {
org: organization(login: "ddev") {
sponsors(first: 100) {
totalCount
nodes {
... on User {
login
url
avatarUrl
sponsorshipForViewerIsActive
}
... on Organization {
login
url
avatarUrl
sponsorshipForViewerIsActive
}
}
}
}
}
organization(login: "ddev") {
... on Sponsorable {
user: user(login: "rfay") {
sponsors(first: 100) {
totalCount
nodes {
... on User {
login
url
avatarUrl
sponsorshipForViewerIsActive
}
... on Organization {
login
url
avatarUrl
sponsorshipForViewerIsActive
}
}
}
}
}
}
`);

// Filter for active sponsors
const activeSponsors = {
rfay: response.user.sponsors.nodes.filter(sponsor => sponsor.sponsorshipForViewerIsActive),
ddev: response.organization.sponsors.nodes.filter(sponsor => sponsor.sponsorshipForViewerIsActive),
};

const rfayData = activeSponsors.rfay.nodes
const orgData = activeSponsors.ddev.nodes
const data = [...rfayData, ...orgData]

console.log("rfayData", rfayData)
console.log("orgData", orgData)
`)

const data = response

putCache(cacheFilename, JSON.stringify(data))

Expand Down

0 comments on commit 10db4b5

Please sign in to comment.