Skip to content

Conversation

@boykisserchan
Copy link
Collaborator

This pull request updates how RSVP counts are fetched and displayed, switching from a direct client-side fetch of an external API to a server-side API route that manages caching and rate limiting. It also improves the freshness and reliability of the displayed count, and makes a minor adjustment to the GitHub commit fetching logic.

RSVP Count Fetching Improvements:

  • Added a new API route in src/pages/api/rsvp.ts that fetches RSVP counts from Airtable, paginates through all records, and caches the result for improved performance and rate limiting. The count is refreshed every 5 seconds.
  • Updated the RSVP component in src/components/RSVP.tsx to use the new /api/rsvp endpoint, reduced the refresh interval to 10 seconds, and improved handling of loading and error states. The component now displays the new count field from the API.

@vercel
Copy link

vercel bot commented Oct 30, 2025

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
aces Ready Ready Preview Comment Oct 31, 2025 1:49pm

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR migrates RSVP count fetching from an external API to an internal Next.js API route with Airtable integration. It adds caching to reduce API calls and simplifies the git API by removing the branch environment logic.

  • Creates a new /api/rsvp endpoint that fetches RSVP counts from Airtable with built-in caching
  • Updates the RSVP component to consume the new internal API endpoint
  • Removes conditional branch logic from the git API, hardcoding to "main"

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 5 comments.

File Description
src/pages/api/rsvp.ts New API route that fetches RSVP count from Airtable with 5-second cache refresh using setInterval
src/components/RSVP.tsx Updated to fetch from new /api/rsvp endpoint instead of external API, adjusted polling interval and response field names
src/pages/api/git.ts Removed branch environment variable logic, hardcoded to "main" branch
bun.lock Added airtable package and its dependencies
Comments suppressed due to low confidence (2)

src/pages/api/rsvp.ts:2

  • Unused import Airtable.
    src/pages/api/rsvp.ts:25
  • Avoid automated semicolon insertion (90% of all statements in the enclosing function have an explicit semicolon).
}

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 29 to 35
setInterval(async () => {
const count = await getCount();
cached = { value: count, updated: Date.now() };
console.log("cached value", cached);
}, 5000);

export default async function handler(_req: NextApiRequest, res: NextApiResponse) {
Copy link

Copilot AI Oct 30, 2025

Choose a reason for hiding this comment

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

Using setInterval at module level in a Next.js API route creates a new interval each time the module is loaded in serverless environments, leading to multiple overlapping timers and memory leaks. In serverless/edge deployments, this approach is unreliable. Consider implementing time-based cache invalidation within the handler function (e.g., checking if cached.updated is stale) or using a separate cron job/scheduled task for cache updates.

Suggested change
setInterval(async () => {
const count = await getCount();
cached = { value: count, updated: Date.now() };
console.log("cached value", cached);
}, 5000);
export default async function handler(_req: NextApiRequest, res: NextApiResponse) {
export default async function handler(_req: NextApiRequest, res: NextApiResponse) {
// Invalidate cache if older than 5 seconds
if (Date.now() - cached.updated > 5000) {
const count = await getCount();
cached = { value: count, updated: Date.now() };
console.log("cached value", cached);
}

Copilot uses AI. Check for mistakes.
Copy link
Collaborator

@thesleepyniko thesleepyniko left a comment

Choose a reason for hiding this comment

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

code mostly lgtm, but do take a look at some of copilots change requests because i do think some of them make sense, so marking as request changes

boykisserchan and others added 2 commits October 30, 2025 07:50
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@thesleepyniko
Copy link
Collaborator

@boykisserchan quick question is this ready for rereview?

@boykisserchan
Copy link
Collaborator Author

im gonna rerequest copilot review once i pus hthis one change and then request one review from like you or ivie

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copy link
Collaborator

@thesleepyniko thesleepyniko left a comment

Choose a reason for hiding this comment

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

lgtm!

@Charmunks Charmunks merged commit 9e6daa6 into main Nov 4, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants