Possible to show output of process on page? #535
Replies: 2 comments 1 reply
-
Hey @parterburn ! Can you expand on your use case a bit more for me? The maintenance tasks gem is ultimately designed to make it easy to perform one-off data changes in production. I don't know if it makes sense to use it as a reporting tool, although you're welcome to write a task that outputs to your application's Rails logger or emits metrics to an observability service like DataDog. |
Beta Was this translation helpful? Give feedback.
-
I was also looking into having some observability on the output of a task. As suggested above, I could just send this data to an external service like Datadog, or go search on the Rails logger, but I am stubborn and wanted it on the task ui. 😄 I did a hack to achieve this, but its not pretty. def persist_progress(number_of_ticks, duration)
update_columns(arguments: arguments.merge("task_results" => task.task_results)) if task.respond_to?(:task_results)
super
end
def start(count)
task.define_singleton_method(:task_results) do
@task_results ||= Hash.new(0)
end
task.task_results.merge!(arguments["task_results"]) if arguments["task_results"]
super
end Then on the task itself whenever I want to record something I have the If anyone else believes they could benefit from this, I can give this idea an extra spin with a cleaner approach. |
Beta Was this translation helpful? Give feedback.
-
Awesome video walkthrough, @adrianna-chang-shopify! In the example, you have
puts element
in the process method, which got me thinking this gem could be a nice drop-in to run some ad-hoc reporting for certain use-cases...if the output of those puts was displayed on the page somewhere.Is that possible with this gem setup by chance?
Beta Was this translation helpful? Give feedback.
All reactions