Run background reports with Sidekiq, not fork

Forking worked in theory but crashed the browser in system specs. It
also came with many other hurdles and isn't well known solution in the
Rails community. Sidekiq can give us better control over execution
limits as well.
This commit is contained in:
Maikel Linke
2023-03-24 16:32:36 +11:00
parent 4c61666fc7
commit 78fea7c7f2
4 changed files with 17 additions and 89 deletions

View File

@@ -55,11 +55,10 @@ module Admin
def render_report_as(format)
if OpenFoodNetwork::FeatureToggle.enabled?(:background_reports, spree_current_user)
job = ReportJob.new
JobProcessor.perform_forked(
job,
job = ReportJob.perform_later(
report_class, spree_current_user, params, format
)
sleep 1 until job.done?
# This result has been rendered by Rails in safe mode already.
job.result.html_safe # rubocop:disable Rails/OutputSafety