Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get GitHub file contributors during getStaticProps, cache to avoid rate limit #12942

Merged
merged 16 commits into from
May 22, 2024

Conversation

wackerow
Copy link
Member

@wackerow wackerow commented May 10, 2024

Description

Updates fetching for GitHub contributors for each page, removing the client-side fetch, replacing with cached solution during getStaticProps (server-side), removing all error/loading conditionals allowing the component the render immediately.

  • Deprecates useClientSideGitHub* hooks
  • Adds new fetchGitHistory.ts script, designed to be run server-side during getStaticProps
  • Implements caching solution to avoid repeating API calls for non-English paths, using in-memory object from the [...slug].tsx] page component that stores already fetched data.
  • This data is now fetched in getStaticProps, and passed forward. Updated consuming components to remove all conditionals, as this data should never be in a loading or error state anymore.
  • Patch: Removed the isDesktop boolean inside FileContributors and replaced with hideBelow="md" to fix the initial patch render glitch where this component was empty to start.

Preview URL

@github-actions github-actions bot added content 🖋️ This involves copy additions or edits dependencies 📦 Changes related to project dependencies needs review 👀 tooling 🔧 Changes related to tooling of the project labels May 10, 2024
Copy link

netlify bot commented May 10, 2024

Deploy Preview for ethereumorg ready!

Name Link
🔨 Latest commit ea4fcba
🔍 Latest deploy log https://app.netlify.com/sites/ethereumorg/deploys/6644de191cb9bf0008401073
😎 Deploy Preview https://deploy-preview-12942--ethereumorg.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
Lighthouse
Lighthouse
7 paths audited
Performance: 50 (🔴 down 6 from production)
Accessibility: 92 (no change from production)
Best Practices: 94 (🔴 down 4 from production)
SEO: 95 (no change from production)
PWA: -
View the detailed breakdown and full score reports

To edit notification comments on pull requests, go to your Netlify site configuration.

@wackerow wackerow marked this pull request as ready for review May 15, 2024 10:18
@wackerow wackerow marked this pull request as draft May 15, 2024 11:15
@wackerow wackerow marked this pull request as ready for review May 15, 2024 16:18
@@ -206,6 +204,7 @@ type DocsLayoutProps = Pick<
| "lastUpdatedDate"
| "crowdinContributors"
| "contentNotTranslated"
| "gitContributors"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that gitContributors and creowdinContributors will be deprecated in #12969 in favor of a single list of contributors

Copy link
Member

@pettinarip pettinarip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGMT! good job @wackerow

@@ -8,13 +8,11 @@ import {
ListItem,
ModalBody,
ModalHeader,
SkeletonText,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bye bye 💀 oh much cleaner now

response.status === 403 &&
response.headers.get("X-RateLimit-Remaining") === "0"
) {
const resetTime = response.headers.get("X-RateLimit-Reset") as string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice use of headers for this, TIL

@pettinarip pettinarip merged commit f166688 into dev May 22, 2024
11 checks passed
@pettinarip pettinarip deleted the get-static-contributors branch May 22, 2024 09:25
This was referenced May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
content 🖋️ This involves copy additions or edits dependencies 📦 Changes related to project dependencies tooling 🔧 Changes related to tooling of the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants