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

Scoped include in search_import not being loaded #1652

Open
GMolini opened this issue Oct 16, 2023 · 0 comments
Open

Scoped include in search_import not being loaded #1652

GMolini opened this issue Oct 16, 2023 · 0 comments

Comments

@GMolini
Copy link

GMolini commented Oct 16, 2023

Ive got a model like this one

class MyModel < ApplicationRecord

  scope :search_import, -> { includes(
    :ordered_b) }

  has_many :a

  has_many :ordered_b, -> { order(creation_date: :desc).includes(:d,:e,:f).limit(50) }, through: :a, source: :b


  def search_data
   {
    bs: ordered_b.map{|b| b.title}
   }
  end
end

The thing is, if I do the scope :search_import, -> { includes( :ordered_b) } the has many relation is not being loaded, and search_data is empty. If I dont do it, reindexing takes longer because it needs to do the query for each object, but the resulting object has the correct data loaded to elastic.

I dont know if its a bug or is just that doing that kind of scoped import is not supported. I cannot import the whole :b relationship because in some instances Ive got too many records and run out of memory

Thanks

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

No branches or pull requests

1 participant