has_moderated
has_moderated copied to clipboard
#preview takes >6000 sql requests and >10 minutes
after a while preview started to work in a very strange way (possibly, because we didn't freeze the version)
here's console output https://gist.github.com/4327657
and here's schema, if needed https://gist.github.com/4327661
can you try to debug this more and figure out what is causing it? play with the parameters a bit or something I have no idea what's wrong, it could be some hooks (after_save etc) you might have in your models that are doing something that causes this
i tried to debug, and came up with using live_preview instead of preview. somehow preview tried to resolve all methods and relations before rollback. i think, this issue can be closed now, thanks. one last question - what's stable version now, so i can freeze it in gemfile?
The last version is stable. Yes preview tries to resolve all relations, because it converts them to arrays. I will leave it open, I might look into it more one time, but glad live_preview works for you.
Happened for me too with preview and not with live_preview. It seems it goes into a loop between the two sides of a has_many through, as it fires lots of single queries for single selects.
Let's say you have A n--------1 X 1--------n B
where the X
is the join table. It looks like this is happening with preview for an object a
of class A
:
- find all related objects of class
B
; - for each of these, find every object of class
A
that is related to it.
Don't know why this happens, it seems a kind of logic loop to me.
Yeah it must be a bug in the preview stuff. Here is the meat of it: https://github.com/mrbrdo/has_moderated/blob/master/lib/has_moderated/moderation_preview.rb#L42 Probably somewhere here is the problem: https://github.com/mrbrdo/has_moderated/blob/master/lib/has_moderated/moderation_preview.rb#L67 It does seem like it will load in all associations (records themselves)?
I will look at it also, but it might take some time as I am really busy these days.