lib/fertile_forest/modules/finders.rb
#
# Find subtree nodes from base node with ordered range.
#
# @param base_obj [Entity|Integer] Base node|id to find.
# @param range [Integer] Ordered range of trunk nodes. -1:To designate as root node.
# @param withTop [boolean] Include base node in return query.
# @param fields [Array] Fields for SELECT clause.
# @return [ActiveRecord::Relation] Basic query for finding subtree nodes.
# @return [nil] No subtree nodes.
#
Find subtree nodes from base node with ordered range.
Find subtree nodes from base node with ordered range .
def subtree(base_obj, range = DESCENDANTS_ALL, with_top = true, columns = nil)
            base_node = ff_resolve_nodes(base_obj)
            return [] if base_node.blank?
            aim_query = ff_required_columns_scope(columns)
              .ff_subtree_scope(
                base_node,
                with_top,
                true   
              )
            ffdd = arel_table[@_ff_depth]
            limited = ff_limited_subtree_depth(
              base_node.ff_depth,
              range,
              aim_query
            )
            aim_query.where!(ffdd.lteq(limited)) if 0 < limited
            aim_query
              .select(ff_all_optional_columns(columns))
              .ff_usual_order_scope()
          end
def subtree ( base_obj , range = DESCENDANTS_ALL , with_top = true , columns = nil ) base_node = ff_resolve_nodes ( base_obj ) return [ ] if base_node . blank? aim_query = ff_required_columns_scope ( columns ) . ff_subtree_scope ( base_node , with_top , true ) ffdd = arel_table [ @_ff_depth ] limited = ff_limited_subtree_depth ( base_node . ff_depth , range , aim_query ) aim_query . where! ( ffdd . lteq ( limited ) ) if 0 < limited aim_query . select ( ff_all_optional_columns ( columns ) ) . ff_usual_order_scope ( ) end
Find subtree nodes from base node with ordered range.
Find subtree nodes from base node with ordered range .
# use COALESCE() must be false for children().count
Basic query for finding subtree nodes.
Basic query for finding subtree nodes .
ActiveRecord::Relation
No subtree nodes.
No subtree nodes .
nil
base_obj
Base node|id to find.
Base node|id to find .
range
Ordered range of trunk nodes. -1:To designate as root node.
Ordered range of trunk nodes . - 1 : To designate as root node .
with_top
<not_specific>
columns
<not_specific>
withTop
<not_specific>
Include base node in return query.
Include base node in return query .
fields
<not_specific>
Fields for SELECT clause.
Fields for SELECT clause .