Skip to content

Introduce support for outdated tasks date threshold#1406

Open
joshmfrankel wants to merge 1 commit intoShopify:mainfrom
joshmfrankel:joshmfrankel/add-support-for-outdated-tasks
Open

Introduce support for outdated tasks date threshold#1406
joshmfrankel wants to merge 1 commit intoShopify:mainfrom
joshmfrankel:joshmfrankel/add-support-for-outdated-tasks

Conversation

@joshmfrankel
Copy link
Contributor

@joshmfrankel joshmfrankel commented Mar 3, 2026

Why

Maintenance tasks are ephermeral by nature. This pull request introduces a mechanism to display a gentle message to encourage removal of Tasks which have not run within the configured threshold.

"Maintenance tasks aren't meant to happen on a regular basis. They're used as needed, or as one-offs. Normally maintenance tasks are ephemeral, so they are used briefly and then deleted."

What

image
  • Add outdated_task_threshold configuration
  • Display message when latest run task is outdated from outdated_task_threshold

Open Questions

  • To avoid any impact, we could introduce support for setting the threshold to nil (alternatively, this could be the default)
  • An alternative to showing the message on each task would be to craft a new section on the tasks#index page which would show the names of outdated tasks in a singular location

@joshmfrankel joshmfrankel force-pushed the joshmfrankel/add-support-for-outdated-tasks branch from 217b6cd to 039de31 Compare March 3, 2026 22:02
@joshmfrankel joshmfrankel marked this pull request as ready for review March 4, 2026 15:26
Comment on lines +79 to +81
within page.find("a", text: "Maintenance::OutdatedTask").find(:xpath, "..").sibling(".has-text-warning") do |element|
assert_text "This task last ran 1 day ago. Consider removing it as it may be outdated."
end
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Future: Might be worthy of a follow-up PR to separate the various sections on the Task#index page within individual parent divs. That would make the lookup easier for testing as well as organizing the DOM.

Copy link
Contributor

@jenshenny jenshenny left a comment

Choose a reason for hiding this comment

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

I think having a way to surface stale tasks would be valuable to have!

# Returns whether the run is beyond the outdated task threshold.
#
# @return [Boolean]
def outdated?
Copy link
Contributor

Choose a reason for hiding this comment

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

outdated doesn't seem like the best fit for this feature as it implies that the task should be updated while I believe we want to convey that the task was run and may not be used anymore.

How about stale ?

# Defaults to 30 days.
#
# @return [ActiveSupport::Duration] the threshold after which a task is considered outdated.
mattr_accessor :outdated_task_threshold, default: 30.days
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a way to opt out of this feature?


alias_method :to_s, :name

delegate :outdated?, to: :related_run
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
delegate :outdated?, to: :related_run
delegate :outdated?, to: :related_run, allow_nil: true

This would raise if related_run is nil. Can we also add a test for if there is no run?

def outdated?
return false unless ended_at.present?

ended_at < MaintenanceTasks.outdated_task_threshold.ago
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we only scope this to succeeded runs only?

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