closure_tree icon indicating copy to clipboard operation
closure_tree copied to clipboard

is it possible to only use deterministic order where parent_id is not null?

Open robguthrie opened this issue 6 years ago • 2 comments

Hello!

I'm looking at using closure_tree on a table with 4 million rows, I want to use a deterministic integer order but only where the record has a parent. Is that possible?

Right now it seems to be trying to put a sequence over all the records in the table, which is taking too long.

robguthrie avatar Aug 26 '17 02:08 robguthrie

I've just tried

      def reorder_with_parent_id(parent_id, minimum_sort_order_value = nil)
        return if parent_id.nil?

Which seems to avoid the issue. Should I try to make this a config option?

robguthrie avatar Aug 26 '17 03:08 robguthrie

@robguthrie So does this mean your roots have nil rank? Or do you set them to default to 0 or 1 or something?

Did you make any progress adding this as a config option?

smoyte avatar May 29 '18 19:05 smoyte