Added gift members to total_members helper#27482
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Run ID: ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (7)
✅ Files skipped from review due to trivial changes (3)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughThis pull request extends the member counting system to track a new "gift" member status category. Changes span type definitions, test fixtures, and utility functions across the admin framework and core Ghost application. The 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
ghost/core/core/frontend/utils/member-count.js (1)
15-17: Default totals fields to0to avoidNaNfrom partial payloads.This code works with the updated response, but a defensive default keeps
totalstable ifthis.datais missinggift.Proposed hardening
- const {free, paid, comped, gift} = memberStats.meta.totals; - let total = free + paid + comped + gift; - return {free, paid, comped, gift, total}; + const {free = 0, paid = 0, comped = 0, gift = 0} = memberStats.meta.totals || {}; + const total = free + paid + comped + gift; + return {free, paid, comped, gift, total};🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@ghost/core/core/frontend/utils/member-count.js` around lines 15 - 17, The destructuring of totals in member-count.js can produce NaN when some fields (e.g., gift) are missing; update the destructure of memberStats.meta.totals in the function that computes total so each of free, paid, comped, and gift defaults to 0 (e.g., use free = 0, paid = 0, comped = 0, gift = 0) before summing into total to ensure total is stable when partial payloads are received.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@ghost/core/core/frontend/utils/member-count.js`:
- Around line 15-17: The destructuring of totals in member-count.js can produce
NaN when some fields (e.g., gift) are missing; update the destructure of
memberStats.meta.totals in the function that computes total so each of free,
paid, comped, and gift defaults to 0 (e.g., use free = 0, paid = 0, comped = 0,
gift = 0) before summing into total to ensure total is stable when partial
payloads are received.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 7bc206b1-0856-455f-8906-5dcee9e6e268
📒 Files selected for processing (7)
apps/admin-x-framework/src/api/stats.tsapps/admin-x-framework/src/test/msw-utils.tsapps/admin-x-framework/src/test/responses/member_count_history.jsonghost/core/core/frontend/utils/member-count.jsghost/core/core/server/services/stats/members-stats-service.jsghost/core/test/unit/frontend/utils/member-count.test.jsghost/core/test/unit/server/services/stats/members.test.js
ref https://linear.app/ghost/issue/BER-3478 Updated the `total_members` helper to include `gift` members in the count
0690031 to
3bd6269
Compare
|
E2E Tests FailedTo view the Playwright test report locally, run: REPORT_DIR=$(mktemp -d) && gh run download 24722261664 -n playwright-report -D "$REPORT_DIR" && npx playwright show-report "$REPORT_DIR" |
1 similar comment
E2E Tests FailedTo view the Playwright test report locally, run: REPORT_DIR=$(mktemp -d) && gh run download 24722261664 -n playwright-report -D "$REPORT_DIR" && npx playwright show-report "$REPORT_DIR" |



ref https://linear.app/ghost/issue/BER-3478
Updated the
total_membershelper to includegiftmembers in the count