Skip to content

Deduplicated revisions when editing automations#28313

Merged
EvanHahn merged 7 commits into
mainfrom
NY-1283_dedupe-automation-revisions
Jun 3, 2026
Merged

Deduplicated revisions when editing automations#28313
EvanHahn merged 7 commits into
mainfrom
NY-1283_dedupe-automation-revisions

Conversation

@troyciesco
Copy link
Copy Markdown
Contributor

@troyciesco troyciesco commented Jun 2, 2026

closes NY-1283

  • Deduplicates automation action revisions in the fake database automations repository so editing an automation only creates a new revision when action data actually changes.
  • Adds unit coverage for unchanged edits, changed wait actions, and newly added actions.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • pnpm-lock.yaml is excluded by !**/pnpm-lock.yaml

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 61633283-99c7-4158-86c6-aad7f899ab8e

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 PR refines the automation action revision persistence layer to insert revisions conditionally rather than unconditionally. When editing an automation's action graph, the code now loads the latest stored revision for each submitted action and compares its persisted data against the incoming action payload using deep equality (dequal). A new revision is inserted only when the data differs. The revision insertion and timestamp-calculation helpers are updated to accept pre-loaded revision information, eliminating redundant database queries. Corresponding unit tests verify that unchanged action data produces no new revisions, modified data increments only the affected action's revision count, and new actions receive their initial revision.

Possibly related PRs

  • TryGhost/Ghost#27878: Updates to the fake automations repository revision logic during graph editing for automations, including conditional action revision inserts, latest revision loading, revision timestamp handling, and revision-count tests.

Suggested labels

ok to merge for me

Suggested reviewers

  • cmraible
  • EvanHahn
🚥 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 and concisely summarizes the main change: deduplicating automation action revisions when editing automations to avoid creating unnecessary revisions.
Description check ✅ Passed The description is clearly related to the changeset, explaining deduplication of automation revisions, linking to the issue, and mentioning added unit test coverage that aligns with the changes.
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 NY-1283_dedupe-automation-revisions

Warning

Review ran into problems

🔥 Problems

Stopped waiting for pipeline failures after 30000ms. One of your pipelines takes longer than our 30000ms fetch window to run, so review may not consider pipeline-failure results for inline comments if any failures occurred after the fetch window. Increase the timeout if you want to wait longer or run a @coderabbit review after the pipeline has finished.


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.

@troyciesco troyciesco force-pushed the NY-1283_dedupe-automation-revisions branch 2 times, most recently from 33ba7a5 to 37f148e Compare June 2, 2026 21:57
@troyciesco troyciesco force-pushed the NY-1283_dedupe-automation-revisions branch from 37f148e to 3c9e76b Compare June 2, 2026 21:57
@troyciesco troyciesco marked this pull request as ready for review June 2, 2026 21:57
Comment on lines +60 to +66
type WaitActionData = Extract<AutomationAction, {type: 'wait'}>['data'];
type SendEmailActionData = Extract<AutomationAction, {type: 'send_email'}>['data'];
type RevisionDataFor<ActionDataT> = {
[FieldT in keyof ActionDataT]: ActionRevisionRow[FieldT & keyof ActionRevisionRow];
};
type WaitRevisionData = RevisionDataFor<WaitActionData>;
type SendEmailRevisionData = RevisionDataFor<SendEmailActionData>;
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.

an attempt at type safety and being able to catch if fields are added/removed. i haven't looked to close at this.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Made a related type safety improvement in e974b16.

@codecov
Copy link
Copy Markdown

codecov Bot commented Jun 2, 2026

Codecov Report

❌ Patch coverage is 80.45977% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 73.72%. Comparing base (87afad8) to head (444d3ee).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
...utomations/fake-database-automations-repository.ts 80.45% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main   #28313      +/-   ##
==========================================
- Coverage   73.73%   73.72%   -0.01%     
==========================================
  Files        1535     1536       +1     
  Lines      130958   131035      +77     
  Branches    15661    15665       +4     
==========================================
+ Hits        96557    96606      +49     
- Misses      33410    33462      +52     
+ Partials      991      967      -24     
Flag Coverage Δ
admin-tests 54.64% <ø> (ø)
e2e-tests 73.72% <80.45%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Now that #28263 is merged, can we move this into ghost/core/test/unit/server/services/automations/automations-repository.test.ts?

Comment on lines +60 to +66
type WaitActionData = Extract<AutomationAction, {type: 'wait'}>['data'];
type SendEmailActionData = Extract<AutomationAction, {type: 'send_email'}>['data'];
type RevisionDataFor<ActionDataT> = {
[FieldT in keyof ActionDataT]: ActionRevisionRow[FieldT & keyof ActionRevisionRow];
};
type WaitRevisionData = RevisionDataFor<WaitActionData>;
type SendEmailRevisionData = RevisionDataFor<SendEmailActionData>;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Made a related type safety improvement in e974b16.

@troyciesco troyciesco requested a review from EvanHahn June 3, 2026 19:55
@EvanHahn EvanHahn merged commit ce6d1ae into main Jun 3, 2026
55 checks passed
@EvanHahn EvanHahn deleted the NY-1283_dedupe-automation-revisions branch June 3, 2026 20:03
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