Skip to content

Started scheduling automation polls with scheduler#27437

Open
EvanHahn wants to merge 1 commit intoseparate-scheduling-and-post-schedulingfrom
NY-1191
Open

Started scheduling automation polls with scheduler#27437
EvanHahn wants to merge 1 commit intoseparate-scheduling-and-post-schedulingfrom
NY-1191

Conversation

@EvanHahn
Copy link
Copy Markdown
Contributor

closes https://linear.app/ghost/issue/NY-1191
ref #27421

Depends on #27421.

Before, we used setTimeout to schedule automation polls (with a TODO).

Now, we properly use the scheduler.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 16, 2026

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

🗂️ Base branches to auto review (1)
  • 6.x

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 3fb01d7d-1e39-4fa0-a5a6-9947cd2ddfa6

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Walkthrough

This pull request introduces an automations polling feature integrated with domain events and a scheduler. Changes include modifying initServices() to instantiate WelcomeEmailAutomationsService with additional configuration (apiUrl, schedulerAdapter, schedulerIntegration), creating a new automations API endpoint module with a poll handler that dispatches domain events, adding the corresponding admin API route and middleware allowlist entry, and updating WelcomeEmailAutomationsService to schedule poll requests through schedulerAdapter instead of using timeouts. Unit tests are added for the automations controller and updated for the service initialization.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'Started scheduling automation polls with scheduler' directly matches the main changeset objective: replacing setTimeout-based scheduling with proper scheduler integration for automation polls.
Description check ✅ Passed The description is directly related to the changeset, explaining the transition from setTimeout to proper scheduler usage for automations polling.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch NY-1191

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.

@EvanHahn

This comment was marked as resolved.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Apr 16, 2026

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

coderabbitai[bot]

This comment was marked as resolved.

@EvanHahn EvanHahn marked this pull request as draft April 16, 2026 18:22
closes https://linear.app/ghost/issue/NY-1191
ref #27421

Before, we used `setTimeout` to schedule automation polls (with a TODO).

Now, we properly use the scheduler.
const timestamp = parseDatabaseDate(run.ready_at);
assert(timestamp >= before);
assert(timestamp <= after);
await db.knex.transaction(async (trx) => {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I recommend reviewing this with whitespace changes disabled. I had to put this in a transaction to avoid the race condition where a member is created and we pick up the run before we can assert on it.

@EvanHahn EvanHahn marked this pull request as ready for review April 16, 2026 18:57
@sonarqubecloud

This comment was marked as resolved.

@EvanHahn EvanHahn requested a review from troyciesco April 16, 2026 21:13
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