lib/fertile_forest/modules/finders.rb
#
# Count each depth for pagination in finding subtree nodes.
# @param base_depth [Integer] Depth of base node.
# @param range [Integer] Ordered depth offset.
# @param subtree_query [Projection] WHERE clause for finding subtree to count.
# @return [Integer] Max depth in query to find subtree nodes.
#
Count each depth for pagination in finding subtree nodes.
Count each depth for pagination in finding subtree nodes .
def ff_limited_subtree_depth(base_depth, range, subtree_query)
            orderd_depth = range == 0 ? 0 : (base_depth + range)
            ffdd = arel_table[@_ff_depth]
            count_query = subtree_query
              .select(ffdd.count('*').as('depth_count'))
              .group(ffdd)
            limited = self.ff_options[:subtree_limit_size]
            total_size = 0
            limited_depth = 0
            count_query.each do |depth_entity|
              aim_depth = depth_entity.ff_depth
              aim_count = depth_entity.depth_count
              braek if limited < total_size += aim_count
              limited_depth = aim_depth
            end
            limited_depth = [limited_depth, base_depth + 1].max
            if orderd_depth == 0
              limited_depth
            else
              [limited_depth, orderd_depth].min
            end
          end
def ff_limited_subtree_depth ( base_depth , range , subtree_query ) orderd_depth = range == 0 ? 0 : ( base_depth + range ) ffdd = arel_table [ @_ff_depth ] count_query = subtree_query . select ( ffdd . count ( '*' ) . as ( 'depth_count' ) ) . group ( ffdd ) limited = self . ff_options [ :subtree_limit_size ] total_size = 0 limited_depth = 0 count_query . each do | depth_entity | aim_depth = depth_entity . ff_depth aim_count = depth_entity . depth_count braek if limited < total_size += aim_count limited_depth = aim_depth end limited_depth = [ limited_depth , base_depth + 1 ] . max if orderd_depth == 0 limited_depth else [ limited_depth , orderd_depth ] . min end end
Count each depth for pagination in finding subtree nodes.
Count each depth for pagination in finding subtree nodes .
Max depth in query to find subtree nodes.
Max depth in query to find subtree nodes .
Integer
base_depth
Depth of base node.
Depth of base node .
range
Ordered depth offset.
Ordered depth offset .
subtree_query
None