Skip to content

Optimized from 20.14 to 0.2#3

Open
egor6240 wants to merge 1 commit intothinknetica:mainfrom
egor6240:day-2,-to-be-optimized
Open

Optimized from 20.14 to 0.2#3
egor6240 wants to merge 1 commit intothinknetica:mainfrom
egor6240:day-2,-to-be-optimized

Conversation

@egor6240
Copy link

No description provided.

Order.destroy_all
# Оптимизировать тут
Array.new(200) { Order.create!(product_id: rand(1..100), quantity: rand(1..10), current_status: :pending) }
Order.delete_all
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

да, поскольку нет связанных объектов, которые нужно было бы удалить. destroy_all удалит и зависимости тоже

batch.each do |order|
threads << Thread.new do

response = send_to_external_service
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

тут ещё можно воспользоваться gem 'async' для неблокирующих запросов

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants