Skip to content

Added gift members to total_members helper#27482

Merged
mike182uk merged 1 commit into
mainfrom
BER-3478-update-total-members-helper
Apr 22, 2026
Merged

Added gift members to total_members helper#27482
mike182uk merged 1 commit into
mainfrom
BER-3478-update-total-members-helper

Conversation

@mike182uk
Copy link
Copy Markdown
Member

ref https://linear.app/ghost/issue/BER-3478

Updated the total_members helper to include gift members in the count

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 21, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e405d42a-dd04-49e6-b669-0958aa0571d8

📥 Commits

Reviewing files that changed from the base of the PR and between 0690031 and 3bd6269.

⛔ Files ignored due to path filters (1)
  • ghost/core/test/e2e-api/admin/__snapshots__/stats.test.js.snap is excluded by !**/*.snap
📒 Files selected for processing (7)
  • apps/admin-x-framework/src/api/stats.ts
  • apps/admin-x-framework/src/test/msw-utils.ts
  • apps/admin-x-framework/src/test/responses/member_count_history.json
  • ghost/core/core/frontend/utils/member-count.js
  • ghost/core/core/server/services/stats/members-stats-service.js
  • ghost/core/test/unit/frontend/utils/member-count.test.js
  • ghost/core/test/unit/server/services/stats/members.test.js
✅ Files skipped from review due to trivial changes (3)
  • ghost/core/test/unit/frontend/utils/member-count.test.js
  • apps/admin-x-framework/src/test/responses/member_count_history.json
  • apps/admin-x-framework/src/api/stats.ts
🚧 Files skipped from review as they are similar to previous changes (3)
  • apps/admin-x-framework/src/test/msw-utils.ts
  • ghost/core/core/server/services/stats/members-stats-service.js
  • ghost/core/core/frontend/utils/member-count.js

Walkthrough

This 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 MemberCountHistoryResponseType is updated to include a gift field in totals, the backend member stats service now derives gift member counts from database records, and frontend utilities are modified to include gift counts in their calculations and returned objects.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically describes the main change: adding gift members to the total_members helper.
Description check ✅ Passed The description is related to the changeset and explains the purpose of the update with a reference to the corresponding issue.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch BER-3478-update-total-members-helper

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

Copy link
Copy Markdown
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.

🧹 Nitpick comments (1)
ghost/core/core/frontend/utils/member-count.js (1)

15-17: Default totals fields to 0 to avoid NaN from partial payloads.

This code works with the updated response, but a defensive default keeps total stable if this.data is missing gift.

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

📥 Commits

Reviewing files that changed from the base of the PR and between d26bfdb and 0690031.

📒 Files selected for processing (7)
  • apps/admin-x-framework/src/api/stats.ts
  • apps/admin-x-framework/src/test/msw-utils.ts
  • apps/admin-x-framework/src/test/responses/member_count_history.json
  • ghost/core/core/frontend/utils/member-count.js
  • ghost/core/core/server/services/stats/members-stats-service.js
  • ghost/core/test/unit/frontend/utils/member-count.test.js
  • ghost/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
@mike182uk mike182uk force-pushed the BER-3478-update-total-members-helper branch from 0690031 to 3bd6269 Compare April 21, 2026 12:26
@sonarqubecloud
Copy link
Copy Markdown

@github-actions
Copy link
Copy Markdown
Contributor

E2E Tests Failed

To 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
@github-actions
Copy link
Copy Markdown
Contributor

E2E Tests Failed

To 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"

@mike182uk mike182uk merged commit 63a1086 into main Apr 22, 2026
75 of 83 checks passed
@mike182uk mike182uk deleted the BER-3478-update-total-members-helper branch April 22, 2026 10:11
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