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

feat: adds revalidate all tutorials endpoint #1684

Open
wants to merge 24 commits into
base: main
Choose a base branch
from

Conversation

kendallstrautman
Copy link
Contributor

@kendallstrautman kendallstrautman commented Feb 24, 2023

πŸ”— Relevant links

πŸ—’οΈ What

Adds a new api endpoint to handle revalidating all tutorials landing, collection and individual tutorial paths. This endpoint will be called after the production content sync is done to bust the cache for all tutorials routes - see related PR

After this PR is merged, I will test the revalidation endpoint before merging the update to the tutorials prod sync workflow.

🀷 Why

πŸ› οΈ How

πŸ“Έ Design Screenshots

πŸ§ͺ Testing

πŸ’­ Anything else?

@vercel
Copy link

vercel bot commented Feb 24, 2023

The latest updates on your projects. Learn more about Vercel for Git β†—οΈŽ

Name Status Preview Comments Updated (UTC)
dev-portal βœ… Ready (Inspect) Visit Preview πŸ’¬ Add feedback Jun 5, 2024 4:46pm

@github-actions
Copy link

Some suggested prefixes and emojis that may help to write clear, actionable code review comments:

Praise πŸ™Œ Question πŸ™‹ Thought πŸ’­ Blocker 🚧 Future πŸ“Œ Optional 🎨 Nitpick ⛏️
Expand for comment prefix descriptions
Prefix+Emoji Description
Praise πŸ™Œ Use to highlight something positive. It's nice to try to leave one per review, but don't leave false praise just to leave one of these comments.
Question πŸ™‹ Use to gain clarity from the code author. The conversation could evolve into any one of these other categories. Only the reviewer should resolve these comment threads.
Thought πŸ’­ Use to share context, leave a breadcrumb, or share an idea that came up while reviewing.
Blocker 🚧 Use to request changes that block merging the current PR. Only the reviewer should resolve these comment threads.
Future πŸ“Œ Use to request changes that the code author can choose to address in the current PR or a follow-up one.
Optional 🎨 Use to suggest optional changes that you feel strongly about but ultimately defer to the code author to make a decision on. These can be comments that turn into valuable conversation starters for adopting new code styles, guidelines, or team practices.
Nitpick ⛏️ Use to suggest changes based on loose opinions or personal preferences. The difference between this and Optional 🎨  is how strong the code reviewer's opinion is.

@github-actions
Copy link

github-actions bot commented Feb 24, 2023

πŸ“¦ Next.js Bundle Analysis

This analysis was generated by the next.js bundle analysis action πŸ€–

This PR introduced no changes to the javascript bundle πŸ™Œ

rawProductSlug === 'well-architected-framework' ||
rawProductSlug === 'onboarding'
) {
if (rawProductSlug in SectionOption) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Random cleanup here

// Loop over all paths to revalidate in batches
// as this endpoint will fire off >1000 revalidation requests
let batchRevalidatePromises = []
for (let i = 0; i < paths.length; i++) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Referenced the batching implementation in the learn api content sync here.

@kendallstrautman kendallstrautman changed the title [wip] Ks.adds revalidate all tutorials feat: adds revalidate all tutorials endpoint Feb 25, 2023
@kendallstrautman kendallstrautman marked this pull request as ready for review February 25, 2023 00:01
@kendallstrautman kendallstrautman requested a review from a team as a code owner February 25, 2023 00:01
Copy link
Contributor

@BRKalow BRKalow left a comment

Choose a reason for hiding this comment

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

I think this is a great first pass at on-demand ISR for tutorials! Nice work.

src/pages/api/revalidate-all-tutorials.ts Outdated Show resolved Hide resolved
Comment on lines 92 to 108
async function getCollectionAndTutorialPaths() {
const collectionPaths = []
const tutorialPaths = []
const allCollections = await getAllCollections()

allCollections.forEach((collection: ClientCollection) => {
// build collection paths
collectionPaths.push(getCollectionSlug(collection.slug))

// build tutorial paths
collection.tutorials.forEach((tutorial: ClientTutorialLite) => {
tutorialPaths.push(getTutorialSlug(tutorial.slug, collection.slug))
})
})

return [...collectionPaths, ...tutorialPaths]
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, I like that the act of getting all of these paths is fairly straightforward.

@kendallstrautman
Copy link
Contributor Author

@BRKalow just removed the delay implementation and left a note for the future on throttling. Lmk if you see any other things to improve ☺️

Copy link
Contributor

@BRKalow BRKalow left a comment

Choose a reason for hiding this comment

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

:shipit: Let's give it a shot!

Copy link
Contributor

@zchsh zchsh left a comment

Choose a reason for hiding this comment

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

πŸ™Œ I'm not super familiar with the revalidation process, but from what I am aware of this looks good to me!

If there are any more detailed testing steps that'd be helpful to dive into, happy to do that πŸ™‡

Comment on lines 95 to 99
const allCollections = await getAllCollections()

allCollections.forEach((collection: ClientCollection) => {
// build collection paths
collectionPaths.push(getCollectionSlug(collection.slug))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nayres this is some code to reference for generating the collection paths!

@kendallstrautman
Copy link
Contributor Author

Testing the full flow from a tutorials action trigger here https://github.com/hashicorp/tutorials/actions/runs/4325350508/jobs/7551391150

@github-actions
Copy link

This PR is stale because it has been open 20 days with no activity. It will be closed in 5 days unless you remove the stale label or comment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants