Skip to content

Conversation

@sweetmantech
Copy link
Collaborator

@sweetmantech sweetmantech commented Nov 14, 2025

Summary by CodeRabbit

  • New Features

    • Enterprise account email aggregation now fetched dynamically from the system (replaces prior static mock data).
  • Bug Fixes

    • Improved error handling with clear error responses when fetching enterprise accounts.
    • Enhanced enterprise email filtering and query behavior for more accurate results.

@coderabbitai
Copy link

coderabbitai bot commented Nov 14, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Adds enterprise-account aggregation and wiring: new getAllEnterpriseAccounts collects account emails by enterprise domains; getArtistsProHandler now calls it and handles errors; getAccountEmails signature and query logic changed; a couple imports/calls updated to match the new API shapes.

Changes

Cohort / File(s) Summary
Enterprise aggregation (new)
lib/enterprise/getAllEnterpriseAccounts.ts
New exported function that iterates ENTERPRISE_DOMAINS, calls getAccountEmails({ queryEmail: "@<domain>" }), accumulates and returns a flat array of AccountEmail objects.
Handler update
controllers/ArtistsProController/getArtistsProHandler.ts
Replaces mock response with call to getAllEnterpriseAccounts(), adds try/catch, returns { status, artists, message? } and logs errors.
Query API refactor
lib/supabase/account_emails/getAccountEmails.ts
Signature changed to getAccountEmails(params: GetAccountEmailsParams) with optional account_id and queryEmail; builds dynamic supabase query with eq and ilike; throws on error.
Callsite / import adjustments
controllers/SubscriptionsController.ts, lib/enterprise/isEnterprise.ts
Updated imports to aliased paths and adjusted getAccountEmails calls to pass parameter objects (e.g., { account_id: accountId }).

Sequence Diagram(s)

sequenceDiagram
    participant Handler as getArtistsProHandler
    participant Aggregator as getAllEnterpriseAccounts
    participant Query as getAccountEmails
    participant DB as Supabase

    Handler->>Aggregator: request enterprise emails
    activate Aggregator
    Aggregator->>Aggregator: for each ENTERPRISE_DOMAINS
    Aggregator->>Query: getAccountEmails({queryEmail: "@domain"})
    activate Query
    Query->>DB: supabase select with ilike / eq
    DB-->>Query: matched account_emails[]
    Query-->>Aggregator: AccountEmail[]
    deactivate Query
    Aggregator-->>Handler: flattened AccountEmail[]
    deactivate Aggregator
    Handler-->>Handler: try/catch -> respond {status, artists, message?}
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Review focal points:
    • getAllEnterpriseAccounts iteration and accumulation (deduping/limits).
    • getAccountEmails new query building and error propagation.
    • Callsites updated to the new params shape (SubscriptionsController, isEnterprise, handlers).

Possibly related PRs

Poem

🐰 I hop through domains, sniffing @ signs,

I gather emails in tidy lines,
No mock remains, the real data sings,
I stitch them up with gentle springs,
Hoppity hops — deployment wings! 🥕

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 addresses the main change: creating a library function to retrieve all enterprise account IDs, which aligns with the addition of getAllEnterpriseAccounts() and related refactoring across the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ea7a897 and c4badf8.

📒 Files selected for processing (1)
  • lib/enterprise/isEnterprise.ts (1 hunks)

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.

@sweetmantech sweetmantech merged commit 1b9b433 into main Nov 14, 2025
1 check passed
Copy link

@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: 1

🧹 Nitpick comments (1)
lib/enterprise/getAllEnterpriseAccounts.ts (1)

11-21: Consider adding resilience for partial query failures.

Currently, if any single domain query fails, the entire operation fails. Depending on requirements, you may want to handle partial failures gracefully and return successful results while logging failures.

If partial results are acceptable, consider using Promise.allSettled:

export const getAllEnterpriseAccounts = async (): Promise<AccountEmail[]> => {
  const allEnterpriseEmails: AccountEmail[] = [];

  // Query for each enterprise domain in parallel
  const emailPromises = Array.from(ENTERPRISE_DOMAINS).map(domain =>
    getAccountEmails({ queryEmail: `@${domain}` })
  );
  
  const results = await Promise.allSettled(emailPromises);
  
  results.forEach((result, index) => {
    if (result.status === 'fulfilled') {
      allEnterpriseEmails.push(...result.value);
    } else {
      const domain = Array.from(ENTERPRISE_DOMAINS)[index];
      console.error(`Failed to fetch emails for domain ${domain}:`, result.reason);
    }
  });

  return allEnterpriseEmails;
};

This approach ensures partial data is still returned even if some domains fail to query.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f3c7238 and ea7a897.

📒 Files selected for processing (5)
  • controllers/ArtistsProController/getArtistsProHandler.ts (1 hunks)
  • controllers/SubscriptionsController.ts (2 hunks)
  • lib/enterprise/getAllEnterpriseAccounts.ts (1 hunks)
  • lib/enterprise/isEnterprise.ts (1 hunks)
  • lib/supabase/account_emails/getAccountEmails.ts (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (3)
lib/enterprise/getAllEnterpriseAccounts.ts (3)
types/database.types.ts (1)
  • Tables (3609-3636)
lib/consts.ts (1)
  • ENTERPRISE_DOMAINS (24-31)
lib/supabase/account_emails/getAccountEmails.ts (1)
  • getAccountEmails (14-36)
controllers/ArtistsProController/getArtistsProHandler.ts (1)
lib/enterprise/getAllEnterpriseAccounts.ts (1)
  • getAllEnterpriseAccounts (11-21)
controllers/SubscriptionsController.ts (1)
lib/supabase/account_emails/getAccountEmails.ts (1)
  • getAccountEmails (14-36)
🔇 Additional comments (6)
lib/enterprise/isEnterprise.ts (1)

1-2: LGTM! Import path normalization.

The import paths have been adjusted to use up-one-directory references, improving consistency across the enterprise modules. No functional changes.

controllers/SubscriptionsController.ts (2)

3-3: LGTM! Import path updated to use alias.

The import path has been updated to use the @/ alias, aligning with the project's path aliasing strategy.


28-28: LGTM! Function call updated to match new signature.

The call to getAccountEmails has been correctly updated to pass an object with account_id property, matching the refactored function signature.

lib/supabase/account_emails/getAccountEmails.ts (2)

6-9: LGTM! Well-designed parameter type for flexible filtering.

The new GetAccountEmailsParams type enables flexible filtering with optional account_id and queryEmail parameters, making the function more versatile.


14-27: LGTM! Clean dynamic query construction.

The function correctly builds queries dynamically based on provided parameters. The conditional filter application using eq for exact match and ilike for pattern matching is appropriate.

controllers/ArtistsProController/getArtistsProHandler.ts (1)

12-27: LGTM! Excellent transition from mock to real data with proper error handling.

The implementation successfully replaces static mock data with dynamic enterprise account fetching. The error handling is comprehensive, including logging and graceful error responses with appropriate status codes.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

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.

2 participants