bulk update through act_as_list_no_update#171
bulk update through act_as_list_no_update#171randoum wants to merge 6 commits intobrendon:masterfrom randoum:master
Conversation
There was a problem hiding this comment.
Do not leave space between ! and its argument.
|
@swanandp the CI error comes from bundle
Shall I do something about that? |
|
I think that calls for a separate PR. Go for it! On Sat, Oct 3, 2015 at 11:05 AM, randoum [email protected] wrote:
|
|
Ok, noted. Let's focus on this one first if you don't mind. What's your feedback? |
|
@swanandp any feedback? Thanks. |
|
Sorry, got held up in other things, will come back to this shortly. |
|
Ok sure. |
|
@swanandp any feedback? Thanks. |
|
@randoum tests have been fixed in master. Could you please rebase and fix hound issues as well? Thanks. |
test/shared_array_scope_list.rb
Outdated
|
I could really use this right now... 😞 I'm updating thousands of items in a list and it's wreaking havoc on my database. |
|
Hi @nickpoorman, sorry to hear that. As a workaround you could use @wikyd, now that @swanandp has had his say, would you like to push this through along his recommendations? |
|
I would like to help, but the proposed changes does not work with our use case. We have a Javascript front-end that allows users to re-order and remove items from the list. Then, we take this set of changes and update our items in a batch use Rails params -> model magic. Turning off callbacks for a specific model does not help in that case. |
|
@wikyd, I've always found this to be the most troubling part of using As a way to mass-assign positions passed in as a list of id's. It can be limited if the list of id's isn't all the id's in the scope though. |
|
@wikyd - I'm actually doing the same thing. We have a bulk upsert endpoint that does a create/destroy/update all in one. For this route, I had to disable paper trail also, as it was creating massive amounts of rows in our ie. @widget.paper_trail.without_versioning do
@widget.update_attributes :name => 'Ford'
end...and it works quite well. |
|
@nickpoorman, they're using some kind of class variable to track the disabled state? I'd assume that wasn't thread safe. |
|
@brendon - I believe it is thread safe: paper-trail-gem/paper_trail#328 |
|
@brendon - I see what they did. They used https://github.com/steveklabnik/request_store to store the state. https://github.com/airblade/paper_trail/blob/8b9ce72f2c449becb3d75b094b9b07fb64b6e908/lib/paper_trail.rb#L62 |
|
@nickpoorman, ah yes, I use that in my applications too. It's handy, but may be brittle to add as a dependency in our case? Will there be any downsides say in the console? |
|
I noticed |
|
@brendon, as far as I can tell |
|
Yes I suppose if the store variable is set and unset cleanly after the block executes then that would be fine. Here's how ancestry is doing it: https://github.com/stefankroes/ancestry/blob/master/lib/ancestry/instance_methods.rb#L296 It's an instance method but is quite spread out in terms of its application in the code. @swanandp, do you have any more thoughts given the latest comments here? |
|
@brendon Definitely need to do the blocking on object level. Let's avoid class or thread level variables unless we have to, and we don't have to here. |
|
Personally I have zero availability. |
|
That's exactly right. I've used RequestStore in the past quite effectively,
but I don't think it's needed here.
…On Wed, 7 Dec 2016 at 1:45 PM, Brendon Muir ***@***.***> wrote:
Thanks @randoum <https://github.com/randoum>, that's all good. I have no
doubts about the quality of RequestStore but as @swanandp
<https://github.com/swanandp> says in this case, it's not necessary to
use a thread level variable so I'd rather not add an unnecessary
dependency. Thanks for your input on this PR to date. :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#171 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAFjGLOthRgDpAVLGjX2sOPC5PYReqJ0ks5rFmsrgaJpZM4GFe7p>
.
|
# The first commit's message is: fix setting position when previous position was nil (#230) * set position properly if starting position is nil * update tests to work with rails 3.2 Closes #109 # This is the 2nd commit message: Show items with same position in higher and lower items (#231) * Show items with same position in higher and lower items * Remove spacing, use update_column instead of update_columns # This is the 3rd commit message: Version 0.8.2 # This is the 4th commit message: Updated Changelog 0.8.2 # This is the 5th commit message: Extract modules (#229) * Convert .acts_as_list to use keyword arguments * Refactoring .acts_as_list: remove configuration variable * Refactoring: use ActiveSupport::Inflector.foreign_key instead of ad-hoc * Refactoring: extract #idify * Refactoring: extract ScopeDefiner module * Refactoring: extract TopOfListDefiner module * Refactoring: extract ColumnDefiner module * Refactoring: extract AddNewAtDefiner module * Refactoring: extract UpdatePositonDefiner module * Refactoring: remove redundant #class_eval call * Refactoring: rename *Definer modules to *MethodDefiner * Refactoring: extract CallbackDefiner module * Refactoring: remove keyword arguments to support Ruby 1.9 * Add a missing dot in comments * Refactoring: merge UpdatePositonMethodDefiner into ColumnMethodDefiner * Refactoring: extract AuxMethodDefiner module # This is the 6th commit message: Add travis config for testing against multiple databases (#236) * Add travis-CI config for tests with postgres / mysql / sqlite # This is the 7th commit message: Use timecop to freeze time for testing # This is the 8th commit message: Compare updated_at with TimeWithZone # This is the 9th commit message: Freeze time at Time.current # This is the 10th commit message: Cache the current time # This is the 11th commit message: Fix non regular sequence movement (#237) # This is the 12th commit message: Be explicit about ordering when mapping :pos in tests (#241) # This is the 13th commit message: Improve load method (#240) * Refactor loading sequence * Fix failing tests # This is the 14th commit message: Fixed tests to prevent warning: too many arguments for format string (#242) # This is the 15th commit message: README update: Adding `acts_as_list` To An Existing Model Closes #210 # This is the 16th commit message: Update README.md (#243) add .all to fix undefined each method in scope option # This is the 17th commit message: bulk update through act_as_list_no_update
This reverts commit f426b10.
This reverts commit 771f8df.
|
I am not sure we can do without If you can do In our case an In terms of use case, you would never write: Because it's plain useless. Instead, you would be using How can you write a block statement that concern multiple record? There's only one way, by using a block at the class level : 2 choices: class instance variable or Thread.current variable. The second one is way safer. So I understand you guys fears toward If rails core team is using it, we can. We are using Some reading : http://stackoverflow.com/questions/7896298/safety-of-thread-current-usage-in-rails |
|
Yeah I messed up big time with git. I have no idea what I did. Finally I deleted my fork and I already started from a fresh one. |
|
Kindly continue there #244 |
|
@wikyd @nickpoorman @StoneFrog if you guys don't mind to participate to #244. Thanks |
To newcomers : The conversation for this PR continues here #244
Allow to perform bulk update by disabling act_as_list callbacks
inspired from http://api.rubyonrails.org/classes/ActiveRecord/NoTouching/ClassMethods.html