fix: add/remove connected repos in DB on itegration update#65
fix: add/remove connected repos in DB on itegration update#65OpeOginni wants to merge 9 commits into
Conversation
|
@OpeOginni is attempting to deploy a commit to the Bounty Team on Vercel. A member of the Team first needs to authorize it. |
📝 WalkthroughWalkthroughGitHub installation handling now fetches and synchronizes repository records for both new and existing organizations. Callback processing accepts installation updates, while repository webhooks process added and removed repositories directly from payload arrays. The integrations page replaces inline uninstall confirmation with Manage GitHub repos and uninstall modal dialogs. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
|
My recent PR introduced a new integrations UI, could you fetch from origin and add this again? @OpeOginni I love this PR a lot, looking forward to merging another banger from you! |
# Conflicts: # apps/web/src/components/layout/app/integrations/integrations-page.tsx
|
@ripgrim Just added a dialog to both the manage and uninstall button letting users know it clears data related to those repo. The extra changes were just format ones, to let the action succeed. |
any chance you could toss in a little screen recording or screenshots? Will review this tomorrow! |
Trimmed.movHere we go |
|
Small bump @ripgrim |
There was a problem hiding this comment.
Actionable comments posted: 2
🧹 Nitpick comments (2)
apps/web/src/lib/github/webhook.ts (1)
176-198: 🚀 Performance & Scalability | 🔵 Trivial | 💤 Low valueDropping the
payload.actiongate and iteratingrepositories_added ?? []/repositories_removed ?? []is more robust since only the relevant array is populated per event. Minor: the added loop is N+1 (per-reposelecttheninsert); consider a batchedinsert ... onConflictDoNothingand a singledelete ... where inArray(githubRepoId, removedIds)if bulk add/remove events are expected.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/lib/github/webhook.ts` around lines 176 - 198, Optimize repository change handling in the added and removed loops: replace per-repository existence checks and inserts with a batched insert using onConflictDoNothing, and replace repeated deletes with one delete constrained by inArray over the removed repository IDs. Preserve the existing org and repository field mappings and logging behavior where practical.apps/web/src/lib/github/install.ts (1)
118-152: 🗄️ Data Integrity & Integration | 🔵 Trivial | 🏗️ Heavy lift
applyRepoSyncis non-transactional and issues N+1 queries; also drops metadata updates.Two concerns on top of the pagination issue flagged above:
- The insert-missing and delete-stale phases run as separate, un-batched statements outside a transaction. A mid-sync failure leaves the DB in a partial state, and the per-repo
select(Line 125-128) is N+1. Wrap the sync indb.transaction(...)and batch the delete viainArray/notInArray.- Existing repos are never updated, so a rename (
name/full_name) or visibility change (private) on GitHub never propagates. ConsideronConflictDoUpdateongithubRepoId.🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@apps/web/src/lib/github/install.ts` around lines 118 - 152, Refactor applyRepoSync to execute atomically inside db.transaction, replace the per-repository existence selects and individual stale deletes with batched operations using onConflictDoUpdate and inArray/notInArray, and update existing records’ name, fullName, and isPrivate fields when GitHub metadata changes. Preserve the stale-repository cleanup while ensuring all inserts, updates, and deletes complete as one transaction.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@apps/web/src/components/layout/app/integrations/integrations-page.tsx`:
- Around line 200-273: Replace the hardcoded border-[`#27272A`] class with
border-tw-border on both DialogClose Cancel buttons in the manageDialogOpen and
confirmingId dialogs, matching the file’s existing design-token styling.
In `@apps/web/src/lib/github/install.ts`:
- Around line 93-116: Update fetchInstallationRepos to retrieve all pages from
the GitHub installation repositories endpoint before returning. Iterate using
the response pagination metadata or page parameters, accumulate every repository
into one array, preserve error handling for failed requests, and return the
complete collection so applyRepoSync does not remove repositories beyond the
first 100.
---
Nitpick comments:
In `@apps/web/src/lib/github/install.ts`:
- Around line 118-152: Refactor applyRepoSync to execute atomically inside
db.transaction, replace the per-repository existence selects and individual
stale deletes with batched operations using onConflictDoUpdate and
inArray/notInArray, and update existing records’ name, fullName, and isPrivate
fields when GitHub metadata changes. Preserve the stale-repository cleanup while
ensuring all inserts, updates, and deletes complete as one transaction.
In `@apps/web/src/lib/github/webhook.ts`:
- Around line 176-198: Optimize repository change handling in the added and
removed loops: replace per-repository existence checks and inserts with a
batched insert using onConflictDoNothing, and replace repeated deletes with one
delete constrained by inArray over the removed repository IDs. Preserve the
existing org and repository field mappings and logging behavior where practical.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: 67abbc8f-fcd0-44b6-9582-3b03f2c2a923
📒 Files selected for processing (4)
apps/web/src/components/layout/app/integrations/integrations-page.tsxapps/web/src/lib/github/install.tsapps/web/src/lib/github/webhook.tsapps/web/src/routes/api/github/callback.ts
Paginate installation repository fetches and use design tokens on dialog Cancel buttons.
Summary
amber-harbor-213
Checklist
Notes for reviewers
Screen.Recording.2026-06-24.at.10.30.29.mov
Summary by CodeRabbit
New Features
Bug Fixes