Skip to content

🐛 Fixed expired complimentary members not updating timestamps#28399

Merged
9larsons merged 1 commit into
mainfrom
codex/fix-expired-comped-updated-at
Jun 6, 2026
Merged

🐛 Fixed expired complimentary members not updating timestamps#28399
9larsons merged 1 commit into
mainfrom
codex/fix-expired-comped-updated-at

Conversation

@9larsons
Copy link
Copy Markdown
Contributor

@9larsons 9larsons commented Jun 6, 2026

Summary

  • updates expired complimentary member cleanup to bump members.updated_at when transitioning members back to free
  • adds a unit test around the worker job using mocked DB and parentPort dependencies

Testing

  • pnpm --dir ghost/core test:single test/unit/server/services/members/clean-expired-comped.test.js
  • pnpm --dir ghost/core exec eslint core/server/services/members/jobs/clean-expired-comped.js test/unit/server/services/members/clean-expired-comped.test.js

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 6, 2026

Review Change Stack

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: 543ebcc7-c564-4380-a029-7da496ceb77e

📥 Commits

Reviewing files that changed from the base of the PR and between 1209593 and 05c74e8.

📒 Files selected for processing (2)
  • ghost/core/core/server/services/members/jobs/clean-expired-comped.js
  • ghost/core/test/unit/server/services/members/clean-expired-comped.test.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • ghost/core/core/server/services/members/jobs/clean-expired-comped.js

Walkthrough

This PR modifies the comped product cleanup job to record a timestamp alongside the member status update. When expired comped members are transitioned to status: 'free', the updated_at field is now set to CURRENT_TIMESTAMP in the same database update operation, and unit tests were added to verify this behavior.

🚥 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 accurately reflects the main change: fixing expired complimentary members not updating timestamps when transitioning to free status.
Description check ✅ Passed The description is directly related to the changeset, clearly explaining the member status update with timestamp bumping and the addition of unit tests.
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 codex/fix-expired-comped-updated-at

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
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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ghost/core/test/integration/services/members/clean-expired-comped.test.js`:
- Around line 63-65: The query retrieving the status event is non-deterministic
because it only filters by member_id; update the
db.knex('members_status_events') lookup in the test to explicitly filter for the
comped→free transition (e.g., status_from = 'comped' and status_to = 'free') and
add a deterministic ordering (e.g., orderBy('created_at', 'desc')) before
calling .first() so the test always picks the intended transition event.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: cd40d0ad-b85f-4aa4-9885-7d15d7347f64

📥 Commits

Reviewing files that changed from the base of the PR and between 4ba6670 and eda185b.

📒 Files selected for processing (2)
  • ghost/core/core/server/services/members/jobs/clean-expired-comped.js
  • ghost/core/test/integration/services/members/clean-expired-comped.test.js

Comment thread ghost/core/test/integration/services/members/clean-expired-comped.test.js Outdated
@9larsons 9larsons force-pushed the codex/fix-expired-comped-updated-at branch from eda185b to 1209593 Compare June 6, 2026 19:19
Expired complimentary tier cleanup updates members directly through knex, which skipped the model timestamp lifecycle and left integrations unable to poll for the transition.
@9larsons 9larsons force-pushed the codex/fix-expired-comped-updated-at branch from 1209593 to 05c74e8 Compare June 6, 2026 19:23
@9larsons 9larsons merged commit 0d0e6de into main Jun 6, 2026
92 of 95 checks passed
@9larsons 9larsons deleted the codex/fix-expired-comped-updated-at branch June 6, 2026 20:00
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