Introduce support for task staleness threshold#1406
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!
* Changed all language of `outdated` to `stale` * Provided an opt-out mechanism by setting MaintenanceTasks.task_staleness_threshold to false * Protected delegated calls to related run being NilClass * Scoped staleness checks to only succeeded Runs
|
@jenshenny Great feedback! I believe I've incorporated all suggestions 🎉 |
jenshenny
left a comment
There was a problem hiding this comment.
This looks good to me pending fixing failing CI
| 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? |
There was a problem hiding this comment.
nit: can we use assert_predicate on these assertions?
| import_posts_task_succeeded_old: | ||
| task_name: Maintenance::ImportPostsTask | ||
| tick_count: 10 | ||
| tick_total: 10 |
There was a problem hiding this comment.
CI is failing since these fields were erroneously deleted
created_at: '01 Jan 2020 00:20:00'
started_at: '01 Jan 2020 00:40:36'
ended_at: '01 Jan 2020 00:52:19'
* Fix missing fixture attributes * Change assert => assert_predicate (and refute)
jenshenny
left a comment
There was a problem hiding this comment.
Apologies in the delay, looks great. Thank you!
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
task_staleness_thresholdconfigurationOpen Questions