From 1676416eef6acd7171804edb6d4438da7543c9c1 Mon Sep 17 00:00:00 2001 From: Randy Fay Date: Mon, 11 Nov 2024 15:58:47 -0700 Subject: [PATCH] Remove expired sponsors from sponsors list (#273) --- src/featured-sponsors.json | 36 ------------------- src/lib/api.ts | 74 +++++++++++++++++++------------------- 2 files changed, 38 insertions(+), 72 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..df6f5e9e 100644 --- a/src/lib/api.ts +++ b/src/lib/api.ts @@ -85,41 +85,35 @@ export async function getSponsors() { } const response = await octokit().graphql(` - query { - user(login: "rfay") { - ... on Sponsorable { - sponsors(first: 100) { - totalCount - nodes { - ... on User { - login - url - avatarUrl - } - ... on Organization { - login - url - avatarUrl - } + query CombinedSponsors { + org: organization(login: "ddev") { + sponsors(first: 100) { + 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 - } - ... on Organization { - login - url - avatarUrl - } + user: user(login: "rfay") { + sponsors(first: 100) { + nodes { + ... on User { + login + url + avatarUrl + } + ... on Organization { + login + url + avatarUrl } } } @@ -127,13 +121,21 @@ export async function getSponsors() { } `) - const rfayData = response.user.sponsors.nodes - const orgData = response.organization.sponsors.nodes - const data = [...rfayData, ...orgData] + // 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 } /**