maintenance_tasks
maintenance_tasks copied to clipboard
Remove one query in `MaintenanceTasks::TasksController#show`
Maybe we could pass the cursor to the task data, and it would build the RunsPage, that way we would load the active runs, load the paginated completed runs, and if we don't have any of these, we could cause the 404. Alternatively we could add a line to the controller, so that the exception leading to the 404 is raised at the end of the controller action, once we know if there's any run or not because we've loaded the active and completed runs. [These two solutions would add a 404 where there's not now: if you "paginate" past the last cursor of a deleted task, right now we will find the last run and show it at the top anyway, but if we only rely on loaded data to know whether to 404, we will get a 404. But it's not much of a problem, the pagination would never get you there, only by changing the cursor in the URL to a value before which there's no run would you get that 404.]
https://github.com/Shopify/maintenance_tasks/pull/667#discussion_r924630874