-
-
Notifications
You must be signed in to change notification settings - Fork 97
Closed
Description
I'm learning about using Rails with Falcon web server. I want to wait for multiple ActiveRecord queries (something like await Promise.all of Javascript). Does the below code do the same effect?
def index
task_query = Task
if @search.present?
task_query = task_query.where('title LIKE ?', "%#{@search}%")
end
barrier = Async::Barrier.new
Async do
barrier.async do
@tasks = task_query.select(:id, :title, :description, :created_at, :updated_at)
.limit(@per_page)
.offset(@offset)
end
barrier.async do
@count = task_query.count(:id)
end
begin
barrier.wait
ensure
barrier.stop
end
end
endPlease correct me if I'm wrong. Thank you so much.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels