-
Notifications
You must be signed in to change notification settings - Fork 25
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
base: main
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git βοΈ
|
Some suggested prefixes and emojis that may help to write clear, actionable code review comments:
Expand for comment prefix descriptions
|
π¦ Next.js Bundle AnalysisThis 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) { |
There was a problem hiding this comment.
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++) { |
There was a problem hiding this comment.
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.
There was a problem hiding this 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.
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] | ||
} |
There was a problem hiding this comment.
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.
@BRKalow just removed the delay implementation and left a note for the future on throttling. Lmk if you see any other things to improve |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's give it a shot!
There was a problem hiding this 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 π
const allCollections = await getAllCollections() | ||
|
||
allCollections.forEach((collection: ClientCollection) => { | ||
// build collection paths | ||
collectionPaths.push(getCollectionSlug(collection.slug)) |
There was a problem hiding this comment.
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!
Co-authored-by: Bryce Kalow <bkalow@hashicorp.com>
5e5b43d
to
8aa825b
Compare
Testing the full flow from a tutorials action trigger here https://github.com/hashicorp/tutorials/actions/runs/4325350508/jobs/7551391150 |
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 |
π 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?