You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
First of all thank you for providing a fresh approach to exporting data. It's just the kind of thing I was looking for. Though very young, this gem has found a place in our controllers and rake tasks dedicated to output data from our DB.
Still... youngness, while sometimes good for freshness, is also sometimes a pain for documentation and comprehension of intents. I had trouble sorting out the necessity of overriding the object_class method, to let specifying whatever-we-wanted-for-export-class-name.
And now I have another bad time with eager-loading. I want to export customers data with a lot of nested classes, so I naively pass a eager-loaded scope to my exporter:
but it does not seems to works by looking at my dev logs.
I also noticed an empty preload! method in the export.rb but I don't really know what to do more for the objects to use eager loading when exporter parses the objects. Any tips on that?
Sorry for not being very clear (not english native). I tried to figure out how Xport::Export class works, but it seems to be much more meta than I can't take! ;)
The text was updated successfully, but these errors were encountered:
Hi, sorry for the long delay, this project is still young and was extracted from one of our private projects, so there are some undocumented/internal features, like preload!, that could be used like:
class MyCustomerExport < Xport::Export
def preload!
@objects = @objects.includes(:addresses, :orders => :order_items)
end
end
Anyway, your example looks ok and it should have preloaded the objects.
Do you receive an error or the preloading doesn't work?
I'm not quite sure how to describe this but even before passing scop, even within preload! method, my "included" scope requests seems to be un-optimised.
When I call sub-elements inside block (or defined method), eager loading seems to be bypassed. I looked again in the gem's code, that should not be occurring as there's a object.each_with_index involved that should keep eager loading for each elements.
Maybe it's a too complex one (lots of nested elements needed for export calculations). I'll try in another simpler export.
Hi!
First of all thank you for providing a fresh approach to exporting data. It's just the kind of thing I was looking for. Though very young, this gem has found a place in our controllers and rake tasks dedicated to output data from our DB.
Still... youngness, while sometimes good for freshness, is also sometimes a pain for documentation and comprehension of intents. I had trouble sorting out the necessity of overriding the
object_class
method, to let specifying whatever-we-wanted-for-export-class-name.And now I have another bad time with eager-loading. I want to export customers data with a lot of nested classes, so I naively pass a eager-loaded scope to my exporter:
but it does not seems to works by looking at my dev logs.
I also noticed an empty
preload!
method in theexport.rb
but I don't really know what to do more for the objects to use eager loading when exporter parses the objects. Any tips on that?Sorry for not being very clear (not english native). I tried to figure out how
Xport::Export
class works, but it seems to be much more meta than I can't take! ;)The text was updated successfully, but these errors were encountered: