Skip to content

Broadcast shows successfullyDelivered#48

Merged
kyphan1 merged 1 commit into
mainfrom
broadcast-successfully-delivered
Aug 13, 2025
Merged

Broadcast shows successfullyDelivered#48
kyphan1 merged 1 commit into
mainfrom
broadcast-successfully-delivered

Conversation

@kyphan1
Copy link
Copy Markdown
Member

@kyphan1 kyphan1 commented Aug 13, 2025

Important

Replace totalReplies with successfullyDelivered in broadcast data model and update related tests and UI components.

  • Data Model:
    • Replace totalReplies with successfullyDelivered in PastBroadcast interface in broadcasts.ts.
  • Tests:
    • Update BatchItem.test.tsx, LastBatchSection.test.tsx, and PastBroadcastsSection.test.tsx to use successfullyDelivered instead of totalReplies.
  • UI Components:
    • Change label from "Responded" to "Delivered successfully" in LastBatchSection.tsx and update the corresponding data field.

This description was created by Ellipsis for 3643677. You can customize this summary. It will automatically update as commits are pushed.

Summary by CodeRabbit

  • New Features

    • Updated broadcast metrics to show “Delivered successfully” instead of “Responded.”
    • Last Batch and Past Broadcasts sections now display the number of successfully delivered messages, with values formatted for readability.
  • Tests

    • Adjusted test fixtures and expectations to align with the new “Delivered successfully” metric and updated values.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Aug 13, 2025

Walkthrough

Replaced PastBroadcast.totalReplies with successfullyDelivered in the API model, updated UI to display “Delivered successfully” using the new field, and adjusted related tests and mock data accordingly. No endpoint or function signatures changed.

Changes

Cohort / File(s) Summary
API model update
src/apis/broadcasts.ts
Added PastBroadcast.successfullyDelivered:number; removed PastBroadcast.totalReplies:number. No endpoint or function signature changes.
UI component update
src/pages/broadcast/LastBatchSection.tsx
Changed label from “Responded” to “Delivered successfully” and value source from totalReplies to successfullyDelivered.
Tests update
src/pages/broadcast/BatchItem.test.tsx, src/pages/broadcast/LastBatchSection.test.tsx, src/pages/broadcast/PastBroadcastsSection.test.tsx
Updated mocks and expectations from totalReplies to successfullyDelivered with corresponding values and labels. No structural test changes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Suggested reviewers

  • nlgthuan

Poem

I twitch my whiskers at stats that once replied,
Now numbers hop to “delivered,” verified.
Fields renamed, the carrots realigned,
Tests burrow through and all’s refined.
Thump-thump—ship it! 🥕✨

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch broadcast-successfully-delivered

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Summary of Changes

Hello @kyphan1, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request refactors the broadcast statistics by replacing the "totalReplies" metric with a more precise "successfullyDelivered" metric. This change ensures that the displayed broadcast data accurately reflects the number of messages that were successfully delivered to recipients, rather than just those that elicited a response.

Highlights

  • API Interface Update: The PastBroadcast interface in src/apis/broadcasts.ts has been updated to include successfullyDelivered and remove totalReplies.
  • UI Metric Renaming: The user interface in src/pages/broadcast/LastBatchSection.tsx now displays "Delivered successfully" instead of "Responded" and uses the new successfullyDelivered data.
  • Test Data Alignment: All relevant test files (BatchItem.test.tsx, LastBatchSection.test.tsx, PastBroadcastsSection.test.tsx) have been updated to reflect the new successfullyDelivered field in their mock data and assertions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point in your pull request via creating an issue comment (i.e. comment on the pull request page) using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in issue comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request correctly replaces the totalReplies field with successfullyDelivered in the PastBroadcast data model and updates all related UI components and tests accordingly. The changes are consistent and align with the description. I have one minor suggestion to improve code clarity in LastBatchSection.tsx by removing a redundant optional chaining operator.

Comment thread src/pages/broadcast/LastBatchSection.tsx
Copy link
Copy Markdown

@ellipsis-dev ellipsis-dev Bot left a comment

Choose a reason for hiding this comment

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

Important

Looks good to me! 👍

Reviewed everything up to 3643677 in 1 minute and 11 seconds. Click for details.
  • Reviewed 108 lines of code in 5 files
  • Skipped 0 files when reviewing.
  • Skipped posting 5 draft comments. View those below.
  • Modify your settings and rules to customize what types of comments Ellipsis leaves. And don't forget to react with 👍 or 👎 to teach Ellipsis.
1. src/apis/broadcasts.ts:22
  • Draft comment:
    Replaced 'totalReplies' with 'successfullyDelivered'. Ensure backend payload matches this update.
  • Reason this comment was not posted:
    Comment looked like it was already resolved.
2. src/pages/broadcast/BatchItem.test.tsx:15
  • Draft comment:
    Updated mock: 'totalReplies' replaced by 'successfullyDelivered'. Consider verifying UI output if needed.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 40% <= threshold 50% The comment suggests verifying the UI output, which is similar to asking the author to double-check something. This violates the rule against asking the author to ensure behavior is intended or tested. However, it does point out a specific change in the code, which could be useful.
3. src/pages/broadcast/LastBatchSection.test.tsx:79
  • Draft comment:
    Updated expected label and number to 'Delivered successfully' with 'successfullyDelivered' prop.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment seems purely informative, as it is just stating what was changed without providing any suggestions or asking for clarification. It doesn't ask for any specific action or confirmation from the PR author.
4. src/pages/broadcast/LastBatchSection.tsx:69
  • Draft comment:
    UI now displays 'Delivered successfully' using the 'successfullyDelivered' field; verify consistency with design.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% The comment is asking the PR author to verify consistency with the design, which falls under asking the author to confirm or double-check something. This violates the rules.
5. src/pages/broadcast/PastBroadcastsSection.test.tsx:43
  • Draft comment:
    Mock data updated: replaced 'totalReplies' with 'successfullyDelivered'.
  • Reason this comment was not posted:
    Comment did not seem useful. Confidence is useful = 0% <= threshold 50% This comment is purely informative, as it only states what was changed without providing any suggestion, question, or request for confirmation. It doesn't align with the rules for useful comments.

Workflow ID: wflow_XoSIgZqNeztGlyuB

You can customize Ellipsis by changing your verbosity settings, reacting with 👍 or 👎, replying to comments, or adding code review rules.

@kyphan1 kyphan1 merged commit 2dcaa5d into main Aug 13, 2025
5 of 6 checks passed
@kyphan1 kyphan1 deleted the broadcast-successfully-delivered branch August 13, 2025 02:40
Copy link
Copy Markdown

@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 (3)
src/pages/broadcast/BatchItem.test.tsx (1)

15-15: Mock updated to new field — looks consistent.
The mock aligns with the PastBroadcast change and other tests in this PR.

If BatchItem renders delivery metrics in its expanded view, consider adding expectations for “Delivered successfully” and “Failed to deliver” to improve coverage.

src/pages/broadcast/PastBroadcastsSection.test.tsx (1)

43-43: Updated mock fields are correct; consider asserting delivery metrics if rendered.
Mocks now use successfullyDelivered, consistent with the API change. If PastBroadcastsSection displays these delivery counts, add assertions to ensure the UI reflects the new field.

Also applies to: 58-58

src/pages/broadcast/LastBatchSection.test.tsx (1)

48-48: Tests correctly reflect the new label/field; add a negative-path test for robustness.
The expectations for “Delivered successfully” and values (95, 950,000) are consistent. Consider adding a test where successfullyDelivered is missing to ensure the component doesn’t throw and shows a fallback (e.g., '—').

Example:

it('handles missing successfullyDelivered gracefully', async () => {
  (useBroadcastsQuery as any).mockReturnValue({
    data: { past: [{ id: 1, runAt: 1619827200, totalFirstSent: 1, totalSecondSent: 1, failedDelivered: 0, totalUnsubscribed: 0 }] },
    isLoading: false,
    isError: false,
  });
  render(<LastBatchSection />);
  expect(await screen.findByText('Delivered successfully')).toBeInTheDocument();
  expect(await screen.findByText('—')).toBeInTheDocument(); // or your chosen fallback
});

Also applies to: 79-80, 95-95, 112-112

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4f08f89 and 3643677.

📒 Files selected for processing (5)
  • src/apis/broadcasts.ts (1 hunks)
  • src/pages/broadcast/BatchItem.test.tsx (1 hunks)
  • src/pages/broadcast/LastBatchSection.test.tsx (4 hunks)
  • src/pages/broadcast/LastBatchSection.tsx (1 hunks)
  • src/pages/broadcast/PastBroadcastsSection.test.tsx (2 hunks)
🔇 Additional comments (1)
src/apis/broadcasts.ts (1)

22-22: Confirm broadcast field rename complete; optional back-compat only if needed

All occurrences of totalReplies in the broadcasts feature have been replaced by successfullyDelivered. A global search shows only two remaining totalReplies references—in src/apis/campaigns.ts and src/pages/campaign/CampaignHistory.tsx—which belong to the separate campaigns feature and aren’t affected by this change.

Since every broadcasts model, UI component, and test now uses successfullyDelivered, it’s safe to remove the old field. If you still need a short migration window for downstream clients, you can add this to PastBroadcast:

/** @deprecated Use successfullyDelivered instead */
totalReplies?: number;

Otherwise, you can proceed without any additional back-compat.

Comment on lines +69 to +71
<span>Delivered successfully</span>
<span className="font-medium tabular-nums text-green-600 dark:text-green-400">
{lastBatch?.totalReplies.toLocaleString()}
{lastBatch?.successfullyDelivered.toLocaleString()}
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue

Guard against undefined values to avoid runtime crashes with partial rollouts.

If the backend response is missing successfullyDelivered (e.g., during phased rollout or for legacy records), calling toLocaleString on undefined will throw. Add a null-safe guard.

Apply this diff:

-            <span className="font-medium tabular-nums text-green-600 dark:text-green-400">
-              {lastBatch?.successfullyDelivered.toLocaleString()}
-            </span>
+            <span className="font-medium tabular-nums text-green-600 dark:text-green-400">
+              {typeof lastBatch?.successfullyDelivered === 'number'
+                ? lastBatch.successfullyDelivered.toLocaleString()
+                : '—'}
+            </span>

Optionally, for short-term back-compat while services roll out, map old -> new at the API boundary (in getBroadcasts) so the UI always has a number:

// inside getBroadcasts after receiving response.data
const data = response.data;
data.past = data.past.map((p: any) => ({
  ...p,
  successfullyDelivered:
    typeof p.successfullyDelivered === 'number'
      ? p.successfullyDelivered
      : typeof p.totalReplies === 'number'
      ? p.totalReplies
      : 0,
}));
return data;
🤖 Prompt for AI Agents
In src/pages/broadcast/LastBatchSection.tsx around lines 69 to 71, the code
calls toLocaleString() on lastBatch?.successfullyDelivered which can be
undefined and crash; update the rendering to guard against undefined (e.g.,
derive a safe number via nullish coalescing or a conditional: use
(lastBatch?.successfullyDelivered ?? 0) before calling toLocaleString, or render
a fallback like "-" when undefined). Optionally implement the suggested API-side
mapping in getBroadcasts to normalize legacy records to always provide a numeric
successfullyDelivered value so the UI can safely assume a number.

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.

1 participant