Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@devkiran
Copy link
Collaborator

@devkiran devkiran commented Sep 30, 2025

Summary by CodeRabbit

  • Bug Fixes
    • Prevents unnecessary link-remapping calls when deleting groups without partners, reducing noise and potential errors.
  • Performance
    • Faster group deletions for groups without partners by skipping redundant background processing.

@vercel
Copy link
Contributor

vercel bot commented Sep 30, 2025

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

Project Deployment Preview Updated (UTC)
dub Building Building Preview Sep 30, 2025 6:19pm

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Sep 30, 2025

Walkthrough

The DELETE handler in apps/web/app/(ee)/api/groups/[groupIdOrSlug]/route.ts now computes partnerIds from group.partners and conditionally triggers the qstash remap-default-links call only when partnerIds.length > 0. The request body uses the partnerIds variable instead of inline mapping.

Changes

Cohort / File(s) Summary
API route: group deletion
apps/web/app/(ee)/api/groups/[groupIdOrSlug]/route.ts
Added partnerIds variable from group.partners, gated the qstash remap-default-links request on partnerIds.length > 0, and replaced inline mapping with partnerIds in the request payload.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  participant C as Client
  participant API as DELETE /api/groups/:idOrSlug
  participant DB as Database
  participant QS as QStash (remap-default-links)

  C->>API: DELETE group
  API->>DB: Fetch group with partners
  alt group found
    API->>DB: Delete group
    API->>API: Compute partnerIds = group.partners.map(id)
    alt partnerIds.length > 0
      API->>QS: POST remap-default-links { partnerIds }
      QS-->>API: Ack
    else No partners
      Note over API: Skip remap request
    end
    API-->>C: 200 OK
  else not found
    API-->>C: 404 Not Found
  end
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

I nudge the code with a gentle hop,
If partners are none, the calls just stop.
When lists have length, we send the ping,
Otherwise, quiet—no extra fling.
Thump-thump! says the prudent rabbit’s art:
Only dispatch when the work should start.

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title Check ✅ Passed The title precisely captures the core change—skipping the /remap-default-links endpoint when a group has no partners—using clear, concise language that directly reflects the updated control flow logic in the DELETE route.
Docstring Coverage ✅ Passed No functions found in the changes. Docstring coverage check skipped.
✨ Finishing touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix-default-links-cron

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 0

🧹 Nitpick comments (1)
apps/web/app/(ee)/api/groups/[groupIdOrSlug]/route.ts (1)

299-309: Conditional execution works but could be cleaner.

The conditional qstash call successfully achieves the PR objective of skipping the remap when no partners exist. However, the use of && inside the Promise.allSettled array results in a false value when the condition isn't met, which is unconventional (though functional).

For cleaner code, consider filtering the promises instead:

     waitUntil(
-      Promise.allSettled([
-        partnerIds.length > 0 &&
-          qstash.publishJSON({
-            url: `${APP_DOMAIN_WITH_NGROK}/api/cron/groups/remap-default-links`,
-            body: {
-              programId,
-              groupId: defaultGroup.id,
-              partnerIds,
-              userId: session.user.id,
-              isGroupDeleted: true,
-            },
-          }),
-
-        recordAuditLog({
+      Promise.allSettled([
+        ...(partnerIds.length > 0
+          ? [
+              qstash.publishJSON({
+                url: `${APP_DOMAIN_WITH_NGROK}/api/cron/groups/remap-default-links`,
+                body: {
+                  programId,
+                  groupId: defaultGroup.id,
+                  partnerIds,
+                  userId: session.user.id,
+                  isGroupDeleted: true,
+                },
+              }),
+            ]
+          : []),
+        recordAuditLog({
           workspaceId: workspace.id,

Note: The PATCH handler (lines 182-188) uses the same && pattern, so this suggestion could apply there as well if you prefer consistency across the file.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 335156f and b2776dc.

📒 Files selected for processing (1)
  • apps/web/app/(ee)/api/groups/[groupIdOrSlug]/route.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
apps/web/app/(ee)/api/groups/[groupIdOrSlug]/route.ts (1)
packages/utils/src/constants/main.ts (1)
  • APP_DOMAIN_WITH_NGROK (20-25)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build
🔇 Additional comments (1)
apps/web/app/(ee)/api/groups/[groupIdOrSlug]/route.ts (1)

295-295: LGTM! Clean extraction of partner IDs.

The extraction of partnerIds before the waitUntil block improves readability and avoids redundant computation.

@steven-tey steven-tey merged commit 32c2cbc into main Sep 30, 2025
6 of 8 checks passed
@steven-tey steven-tey deleted the fix-default-links-cron branch September 30, 2025 18:23
@coderabbitai coderabbitai bot mentioned this pull request Nov 8, 2025
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.

3 participants