Introduce support for outdated tasks date threshold#1406
Introduce support for outdated tasks date threshold#1406joshmfrankel wants to merge 1 commit intoShopify:mainfrom
Conversation
217b6cd to
039de31
Compare
| 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 |
There was a problem hiding this comment.
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.
jenshenny
left a comment
There was a problem hiding this comment.
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? |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
Is there a way to opt out of this feature?
|
|
||
| alias_method :to_s, :name | ||
|
|
||
| delegate :outdated?, to: :related_run |
There was a problem hiding this comment.
| 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 |
There was a problem hiding this comment.
Can we only scope this to succeeded runs only?
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
outdated_task_thresholdconfigurationOpen Questions