From 1d06856fcf6998cb51ab232334c130608e049111 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Fri, 8 Nov 2024 15:00:49 -0700 Subject: [PATCH 1/4] Remove expired sponsors from sponsors list --- src/featured-sponsors.json | 36 ------------------------------------ src/lib/api.ts | 4 ++-- 2 files changed, 2 insertions(+), 38 deletions(-) diff --git a/src/featured-sponsors.json b/src/featured-sponsors.json index 1b6023ba..7d2589d3 100644 --- a/src/featured-sponsors.json +++ b/src/featured-sponsors.json @@ -33,24 +33,6 @@ "url": "https://openstrategypartners.com/", "github": "open-strategy-partners" }, - { - "name": "1xINTERNET", - "type": "standard", - "logo": "/logos/1xinternet.svg", - "darklogo": "/logos/1xinternet.svg", - "squareLogo": "/logos/1xinternet-square.svg", - "url": "https://1xinternet.de", - "github": "1xINTERNET" - }, - { - "name": "Amazee.io", - "type": "standard", - "logo": "/logos/amazee-io-Mirantis-Logo-Black-White-IO.svg", - "darklogo": "/logos/amazee-io-mirantis-darkmode.svg", - "squareLogo": "/logos/amazee-io-square.svg", - "url": "https://amazee.io/", - "github": "amazee.io" - }, { "name": "Agaric", "type": "standard", @@ -105,15 +87,6 @@ "url": "https://gizra.com/", "github": "gizra" }, - { - "name": "DrupalEasy", - "type": "standard", - "logo": "/logos/drupaleasy.png", - "darklogo": "/logos/drupaleasy-darkmode.png", - "squareLogo": "/logos/drupaleasy-square.svg", - "url": "https://www.drupaleasy.com/", - "github": "drupaleasy" - }, { "name": "mobilistics", "type": "standard", @@ -175,14 +148,5 @@ "squareLogo": "/logos/craft-cms-square.svg", "url": "https://craftcms.com/", "github": "craftcms" - }, - { - "name": "undpaul", - "type": "standard", - "logo": "/logos/undpaul.svg", - "darklogo": "/logos/undpaul-darkmode.svg", - "squareLogo": "/logos/undpaul-square.svg", - "url": "https://undpaul.de", - "github": "undpaul" } ] diff --git a/src/lib/api.ts b/src/lib/api.ts index 7c2d75ba..5b9fa7ad 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -88,7 +88,7 @@ export async function getSponsors() { query { user(login: "rfay") { ... on Sponsorable { - sponsors(first: 100) { + sponsors(first: 100, isActive: true) { totalCount nodes { ... on User { @@ -107,7 +107,7 @@ export async function getSponsors() { } organization(login: "ddev") { ... on Sponsorable { - sponsors(first: 100) { + sponsors(first: 100, isActive: true) { totalCount nodes { ... on User { From d9477dca3be3af18ecf442523304560fc91c7a2f Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Fri, 8 Nov 2024 16:16:18 -0700 Subject: [PATCH 2/4] try to use filtered info --- src/lib/api.ts | 81 +++++++++++++++++++++++++++++--------------------- 1 file changed, 47 insertions(+), 34 deletions(-) diff --git a/src/lib/api.ts b/src/lib/api.ts index 5b9fa7ad..054661c3 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -85,51 +85,64 @@ export async function getSponsors() { } const response = await octokit().graphql(` - query { - user(login: "rfay") { - ... on Sponsorable { - sponsors(first: 100, isActive: true) { - totalCount - nodes { - ... on User { - login - url - avatarUrl - } - ... on Organization { - login - url - avatarUrl - } + query { + user(login: "rfay") { + ... on Sponsorable { + sponsors(first: 100) { + totalCount + nodes { + ... on User { + login + url + avatarUrl + sponsorshipForViewerIsActive + } + ... on Organization { + login + url + avatarUrl + sponsorshipForViewerIsActive } } } } - organization(login: "ddev") { - ... on Sponsorable { - sponsors(first: 100, isActive: true) { - totalCount - nodes { - ... on User { - login - url - avatarUrl - } - ... on Organization { - login - url - avatarUrl - } + } + organization(login: "ddev") { + ... on Sponsorable { + 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 = response.user.sponsors.nodes - const orgData = response.organization.sponsors.nodes + const rfayData = activeSponsors.rfay.nodes + const orgData = activeSponsors.ddev.nodes const data = [...rfayData, ...orgData] + + console.log("rfayData", rfayData) + console.log("orgData", orgData) putCache(cacheFilename, JSON.stringify(data)) From 10db4b5b07fd8450543d1f83feb4cc73b3e6bc58 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Fri, 8 Nov 2024 17:14:20 -0700 Subject: [PATCH 3/4] Use a better overall query --- src/lib/api.ts | 33 ++++++--------------------------- 1 file changed, 6 insertions(+), 27 deletions(-) diff --git a/src/lib/api.ts b/src/lib/api.ts index 054661c3..296a5fa1 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -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)) From 2600bc74a2912c6d5d1a4ddb3340568290283dfd Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Fri, 8 Nov 2024 17:23:07 -0700 Subject: [PATCH 4/4] Combine sponsors so we can walk them --- src/lib/api.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/lib/api.ts b/src/lib/api.ts index 296a5fa1..df6f5e9e 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -121,11 +121,21 @@ export async function getSponsors() { } `) - const data = response + // Combine sponsors from both sources and remove duplicates + const allSponsors = [ + ...response.org.sponsors.nodes, + ...response.user.sponsors.nodes + ].reduce((unique, sponsor) => { + // Use login as unique identifier + if (!unique.some(item => item.login === sponsor.login)) { + unique.push(sponsor) + } + return unique + }, []) - putCache(cacheFilename, JSON.stringify(data)) + putCache(cacheFilename, JSON.stringify(allSponsors)) - return data + return allSponsors } /**