closure_tree icon indicating copy to clipboard operation
closure_tree copied to clipboard

Best approach to counter_cache and summarization

Open narath opened this issue 9 years ago • 1 comments

Closure tree looks great. I need to be able to report out on count (count the number of all descendents) and do some other summarization (summing points for the node and all children). Is there a recommended approach for this? Would counter_cache work appropriately for the node object? For the more complicated summarization (summing points and totals for all descendents) are their custom callbacks that can be used?

narath avatar Sep 25 '16 16:09 narath

I have the same question. At least an option for counter_cache on parent relation would be nice. awesome_nested_set has such a thing and it's quite useful because we filter out some entries with no children (empty placeholder threads in comments).

//EDIT:

reflections["parent"].options[:counter_cache] = :children_count

2called-chaos avatar Feb 23 '17 16:02 2called-chaos