Open xdmx opened 15 years ago
I'm not sure. When you say the structure is corrupt, is it corrupt right after the deletes, as in, have you reloaded the objects you are examining for correctness? I haven't had any problems. I'm using a smaller number of items in our case, but I don't see how the number would matter at all (the code either works or it doesn't). Are any exceptions being thrown?
Hi chris, yes, i reloaded the objects after the deletes. For example before the script, i had a structure like this:
root
a
a1
a11
a12
a2
a3
b
b1
b2
b3
etc..
Then after the creation/destroy i had something like:
root
a
a1
a11
a12
a2
a3
b
b1
b2
b3
etc..
Having another group of categories under another child (luckily only for lft and rgt, parent_id wasn't touched so i was able to just run a renumber_full_tree)
The only problem i think about is that i got all the categories and then checked them, like Category.all.each do |category| category.destroy if category.something = '...' and category.all_children_count.zero? end
Without reloading all the categories, but i think that this isn't the problems as in the before_destroy of the plugin there is a: self.reload # in case a concurrent move has altered the indexes which should be the solution for this cases
There weren't any exceptions or other outputs (just that for the destroy it took a while, as there are a lot of records to update, i think)
Usually it works correctly when you create/destroy a single object, but having a lot of them it collapsed, i don't know if maybe because the db (mysql), the plugin or what else :)
Just an OT question, do you think that there would be problems having a lot (1-2 millions) of children under a single root? I mean, about updates and stuff like that... if you add/destroy a child at the start and it has to update thousands/millions of rows with the new lft/rgt i think it would take quite a lot (and we know that users hate to wait too long :( )
Hi, i'm using this plugin to manage a structure of categories (one single root with, at now, 12-15000 children). I've noticed that running a simple script which create categories one after one at the end i had all the structure corrupted (lft and rgt not correct). I run a renumber_full_tree and everything went right again. Then i removed some (~2-3000) categories with another simple script using the destroy method and after some (100-200) i had again all the structure broken. Then i used the delete method and called at the end the renumber_full_tree again, and it went right. I'm very worried about this because the categories will increase exponentially (like one root and 500'000, 1'000'000 or even more children), and having this trouble would make all the website broken. Do you know what would it be the cause?