app/models/hierarchy/merge_by_name.rb
# TODO: not sure if I want to walk down by depth, or (as here), down the
# graph. Need to feel it out...
not sure if I want to walk down by depth, or (as here), down the
graph. Need to feel it out
not sure if I want to walk down by depth or ( as here ) down the graph . Need to feel it out
def merge_tree(root)
      @matches = {}
      @ancestry = {}
      descendants = @hierarchy.entries.active.
        select(@entry_attributes).
        includes(name: { canonical_form: :name },
          synonyms: { name: { canonical_form: :name } }).
        where(["lft BETWEEN ? AND ?", root.lft, root.rgt]).
        order(:lft)
      descendants.find_each do |entry|
        find_matches(entry)
      end
    end
def merge_tree ( root ) @matches = { } @ancestry = { } descendants = @hierarchy . entries . active . select ( @entry_attributes ) . includes ( name : { canonical_form : :name } , synonyms : { name : { canonical_form : :name } } ) . where ( [ "lft BETWEEN ? AND ?" , root . lft , root . rgt ] ) . order ( :lft ) descendants . find_each do | entry | find_matches ( entry ) end end
TODO: not sure if I want to walk down by depth, or (as here), down the
graph.
TODO : not sure if I want to walk down by depth or ( as here ) down the graph .
# We reset the hash of merges for each new tree, but make it an instance # variable so we don't have to pass it around. # Same: we want to know ancestry as we walk down the tree, so we can check # for previous merges. # TODO: Hmmmn... tricky: we want to stop when we've found a virus.
root
<not_specific>