Skip to content

Commit 512ba91

Browse files
committed
chore: standardize naming for GitHub sponsor supporter and update API key handling
1 parent 492c9ed commit 512ba91

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

.github/workflows/playwright-cloudflare-open-next.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ jobs:
5656
env:
5757
PLAYWRIGHT_RUN_CLOUDFLARE_PREVIEW: true
5858
PLAYWRIGHT_BASE_URL: http://127.0.0.1:8787
59+
GITHUB_READ_API_KEY: ${{ secrets.GITHUB_READ_API_KEY }}
5960

6061
- name: Upload Playwright test results
6162
if: always()

apps/site/next-data/generators/supportersData.mjs

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ async function fetchOpenCollectiveData() {
112112
* Fetches supporters data from Github API, filters active backers,
113113
* and maps it to the Supporters type.
114114
*
115-
* @returns {Promise<Array<import('#site/types/supporters').GithubSponsorSupporter>>} Array of supporters
115+
* @returns {Promise<Array<import('#site/types/supporters').GitHubSponsorSupporter>>} Array of supporters
116116
*/
117117
async function fetchGithubSponsorsData() {
118118
if (!GITHUB_READ_API_KEY) {
@@ -215,18 +215,27 @@ const graphql = async (query, variables = {}) => {
215215
* Fetches supporters data from Open Collective API and GitHub Sponsors, filters active backers,
216216
* and maps it to the Supporters type.
217217
*
218-
* @returns {Promise<Array<import('#site/types/supporters').OpenCollectiveSupporter | import('#site/types/supporters').GithubSponsorSupporter>>} Array of supporters
218+
* @returns {Promise<Array<import('#site/types/supporters').OpenCollectiveSupporter | import('#site/types/supporters').GitHubSponsorSupporter>>} Array of supporters
219219
*/
220220
async function sponsorsData() {
221221
const seconds = 300; // Change every 5 minutes
222222
const seed = Math.floor(Date.now() / (seconds * 1000));
223223

224-
const sponsors = await Promise.all([
224+
const sponsorsResults = await Promise.allSettled([
225225
fetchGithubSponsorsData(),
226226
fetchOpenCollectiveData(),
227227
]);
228228

229-
const shuffled = await shuffle(sponsors.flat(), seed);
229+
const sponsors = sponsorsResults.flatMap(result => {
230+
if (result.status === 'fulfilled') {
231+
return result.value;
232+
}
233+
234+
console.error('Supporters data source failed:', result.reason);
235+
return [];
236+
});
237+
238+
const shuffled = await shuffle(sponsors, seed);
230239

231240
return shuffled;
232241
}

apps/site/types/supporters.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ export type Supporter<T extends string> = {
77
};
88

99
export type OpenCollectiveSupporter = Supporter<'opencollective'>;
10-
export type GithubSponsorSupporter = Supporter<'github'>;
10+
export type GitHubSponsorSupporter = Supporter<'github'>;

0 commit comments

Comments
 (0)