Rails progress bar during query execution

I have several MySQL queries that take a lot of time, and I would like to display a progress bar while I work. Is this possible in Rails with jquery? Does ActiveRecord have any mechanisms for this?

Really? No ideas? Then how about this:

I have requests separated by a line, (connection.execute), is it possible to call something that will resemble a progress bar between request calls?

+4
source share
1 answer

It's not a problem. Create a wrapper to execute the query, for example:

def execute_sql(sql_string) results = [] ActiveRecord::Base.transaction do sql_string.split(';').each do |sql_query| if sql_query.present? result = ActiveRecord::Base.connection.execute(sql_query) results << result if result your_progress = results.length end end end end 
0
source

Source: https://habr.com/ru/post/1387006/


All Articles