Skip to content

Commit

Permalink
address feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
d-m-u committed Jan 26, 2021
1 parent 7a1dfc4 commit 1d7517b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion db/migrate/20200607025146_add_ancestry_to_vm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def transfer_relationships_to_ancestry(dest_model, resource_type, relationship)

# src is vm, dest is relationship
def create_relationships_from_ancestry(src_model, dest_model, resource_type, relationship)
children = src_model.select("ancestry::bigint").where("ancestry not like '%/%'")
children = src_model.select("ancestry::bigint").where("ancestry NOT LIKE '%/%'")
rels = src_model.where.not(:ancestry => nil).or(src_model.where(:id => children)).map do |obj|
dest_model.create!(:relationship => relationship,
:resource_type => resource_type,
Expand Down
3 changes: 2 additions & 1 deletion spec/migrations/20200607025146_add_ancestry_to_vm_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -167,8 +167,9 @@ def traverse(tree, parent, &block)
yield(parent, key)
traverse(children, parent + [key], &block)
end
when nil
else
puts "curious type: #{tree.class.name}"
raise StandardError, "curious type: #{tree.class.name}"
end
end

Expand Down

0 comments on commit 1d7517b

Please sign in to comment.