Skip to content

Combined "enqueue automations poll" operations into one#27909

Merged
troyciesco merged 1 commit into
mainfrom
enqueue-poll-consolidation
May 25, 2026
Merged

Combined "enqueue automations poll" operations into one#27909
troyciesco merged 1 commit into
mainfrom
enqueue-poll-consolidation

Conversation

@EvanHahn
Copy link
Copy Markdown
Contributor

towards https://linear.app/ghost/issue/NY-1286

This change should have no user impact.

Before (pseudocode):

const enqueuePollNow = () => {
    dispatch(StartAutomationsPollEvent.create());
};
const enqueuePollAt = (date) => {
    scheduler.at(date, 'PUT', '/automations/poll');
};

After (pseudocode):

const enqueuePollAt = (date) => {
    if (new Date() < date) {
        dispatch(StartAutomationsPollEvent.create());
    } else {
        scheduler.at(date, 'PUT', '/automations/poll');
    }
};

I think this is a useful change on its own (makes it easier for functions that want this behavior), but it'll also make an upcoming change easier.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 15, 2026

Review Change Stack

Important

Review skipped

Draft detected.

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: 0b617e20-004c-4525-b6c2-277e7e0eda83

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:

  • ✅ Review completed - (🔄 Check again to review again)

Walkthrough

This PR refactors the automation polling scheduler to unify immediate and deferred scheduling. The AutomationsService introduces a single enqueuePollAt(date) method that consolidates the separate "poll now vs. later" pathways: it dispatches StartAutomationsPollEvent immediately when the date is not in the future, otherwise schedules for later. The poll runner's options contract removes enqueueAnotherPollNow and uses only enqueueAnotherPollAt for all follow-up scheduling. Tests are updated to remove all enqueueAnotherPollNow mocks and assertions, with stricter timing validation in the batch limit case.

Suggested reviewers

  • troyciesco
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly describes the main change: consolidating two separate enqueue operations into one unified operation for automations polling.
Description check ✅ Passed The description is well-related to the changeset, providing context, before/after pseudocode, and rationale for the consolidation of automations poll enqueuing operations.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch enqueue-poll-consolidation

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 EvanHahn marked this pull request as draft May 20, 2026 15:16

This comment was marked as outdated.

@EvanHahn EvanHahn force-pushed the enqueue-poll-consolidation branch from 61ed318 to 46ff89a Compare May 24, 2026 21:11
@EvanHahn EvanHahn marked this pull request as ready for review May 24, 2026 21:11
@EvanHahn

This comment was marked as outdated.

@coderabbitai

This comment was marked as outdated.

towards https://linear.app/ghost/issue/NY-1286

This change should have no user impact.

Before (pseudocode):

```
const enqueuePollNow = () => {
    dispatch(StartAutomationsPollEvent.create());
};
const enqueuePollAt = (date) => {
    scheduler.at(date, 'PUT', '/automations/poll');
};
```

After (pseudocode):

```
const enqueuePollAt = (date) => {
    if (new Date() < date) {
        dispatch(StartAutomationsPollEvent.create());
    } else {
        scheduler.at(date, 'PUT', '/automations/poll');
    }
};
```

I think this is a useful change on its own, but it'll also make [an
upcoming change][0] easier.

[0]: https://linear.app/ghost/issue/NY-1286
@EvanHahn EvanHahn force-pushed the enqueue-poll-consolidation branch from 46ff89a to 7a12c14 Compare May 24, 2026 21:33
@EvanHahn EvanHahn requested a review from troyciesco May 24, 2026 21:53
@troyciesco troyciesco merged commit c4e7f6b into main May 25, 2026
44 checks passed
@troyciesco troyciesco deleted the enqueue-poll-consolidation branch May 25, 2026 13:25
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