Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Background processing in CatalogController#catalog_push #4

Open
chinshr opened this issue Dec 5, 2014 · 1 comment
Open

Background processing in CatalogController#catalog_push #4

chinshr opened this issue Dec 5, 2014 · 1 comment

Comments

@chinshr
Copy link
Contributor

chinshr commented Dec 5, 2014

The catalog_push is one of the slowest actions. I would like it to add background processing for CatalogController#catalog_push, which should speed things up quite a bit.

I have pull request ready, but since the call is async I would need to use a callback providing import errors to an endpoint on the RetailOps side. Do you think that is feasible?

The job looks like this, and I would need to implement Spree::Api::Ratailops.import_results in this example:

class Spree::Retailops::CatalogJob < ActiveJob::Base
  queue_as :default

  attr_reader :params

  def initialize
    @params = {}
    @diag   = []
    @memo   = {}
    @failed = {}
  end

  def perform(products, params = {})
    @params = params

    products.to_a.each { |pd| upsert_product_and_variants(pd) }

    Spree::Api::Ratailops.import_results(@diag)
  end

  private
    include Spree::Api::Retailops::CatalogHelpers
end

CatalogController would add this line:

...
class CatalogController
  ...
  def catalog_push
    ...
    Spree::Retailops::CatalogJob.perform_later(products, params)
    ...
   end
...
@chinshr
Copy link
Contributor Author

chinshr commented Dec 5, 2014

@sorear Would be great to get your feedback.

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

No branches or pull requests

1 participant