-
Notifications
You must be signed in to change notification settings - Fork 107
Introduce support for task staleness threshold #1406
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
jenshenny
merged 5 commits into
Shopify:main
from
joshmfrankel:joshmfrankel/add-support-for-outdated-tasks
Apr 9, 2026
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
039de31
Introduce support for outdated tasks date threshold
joshmfrankel 2ee0a43
Recycle requested changes from review
joshmfrankel 22753d6
Merge branch 'main' into joshmfrankel/add-support-for-outdated-tasks
jenshenny abde366
Recycle PR comments
joshmfrankel c011970
Fix Rubocop issue
joshmfrankel File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| module Maintenance | ||
| class StaleTask < MaintenanceTasks::Task | ||
| def collection | ||
| [1, 2] | ||
| end | ||
|
|
||
| def process(number) | ||
| Rails.logger.debug("This task is stale") | ||
| end | ||
| end | ||
| end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -773,6 +773,50 @@ class RunTest < ActiveSupport::TestCase | |
| end | ||
| end | ||
|
|
||
| test "#stale? returns `false` when the run is not succeeded" do | ||
| MaintenanceTasks.with(task_staleness_threshold: 1.day) do | ||
| run = Run.create!(task_name: "Maintenance::UpdatePostsTask", ended_at: 2.days.ago, status: :running) | ||
| refute run.stale? | ||
|
||
| end | ||
| end | ||
|
|
||
| test "#stale? returns `false` when the staleness threshold is disabled" do | ||
| MaintenanceTasks.with(task_staleness_threshold: false) do | ||
| run = Run.create!(task_name: "Maintenance::UpdatePostsTask", ended_at: 2.days.ago, status: :succeeded) | ||
| refute run.stale? | ||
| end | ||
| end | ||
|
|
||
| test "#stale? returns `true` when the run is succeeded and beyond the default staleness threshold" do | ||
| run = Run.create!( | ||
| task_name: "Maintenance::UpdatePostsTask", | ||
| ended_at: (MaintenanceTasks.task_staleness_threshold + 1.day).ago, | ||
| status: :succeeded, | ||
| ) | ||
| assert run.stale? | ||
| end | ||
|
|
||
| test "#stale? returns `true` when the run is succeeded and beyond the staleness threshold" do | ||
| MaintenanceTasks.with(task_staleness_threshold: 1.day) do | ||
| run = Run.create!(task_name: "Maintenance::UpdatePostsTask", ended_at: 2.days.ago, status: :succeeded) | ||
| assert run.stale? | ||
| end | ||
| end | ||
|
|
||
| test "#stale? returns `false` when the run is succeeded and within the staleness threshold" do | ||
| MaintenanceTasks.with(task_staleness_threshold: 2.day) do | ||
| run = Run.create!(task_name: "Maintenance::UpdatePostsTask", ended_at: 1.day.ago, status: :succeeded) | ||
| refute run.stale? | ||
| end | ||
| end | ||
|
|
||
| test "#stale? returns `false` when the run is nil" do | ||
| MaintenanceTasks.with(task_staleness_threshold: 1.day) do | ||
| run = Run.new | ||
| refute run.stale? | ||
| end | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def expected_notification(run) | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
CI is failing since these fields were erroneously deleted