{"action":"created","comment":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/87050581","pull_request_review_id":7678407,"id":87050581,"diff_hunk":"@@ -186,6 +186,56 @@ def save_inventory_multi(association, hashes, deletes, find_key, child_keys = []\n     association.push(new_records)\n   end\n \n+  def save_inventory_multi_child(rel_type, association, parent, hashes, find_key, child_keys = [], extra_keys = [],\n+                                 disconnect = false)\n+    association.reset\n+    deletes = parent.send(rel_type).to_a\n+    child_keys = Array.wrap(child_keys)\n+    remove_keys = Array.wrap(extra_keys) + child_keys\n+    record_index = TypedIndex.new(association, find_key)\n+\n+    new_records = []\n+    hashes.each do |h|\n+      found = save_inventory_with_multi_findkey(rel_type, association, parent, h.except!(*remove_keys), record_index,\n+                                                new_records, deletes)\n+      save_child_inventory(found, h, child_keys)\n+    end\n+\n+    unless deletes.blank?\n+      _log.info(\"[#{rel_type[0...-1].titleize}] Deleting #{log_format_deletes(deletes)}\")\n+      delete_multi(rel_type, deletes, parent, disconnect)\n+    end\n+\n+    parent.send(rel_type) << new_records\n+    parent.save!\n+  end\n+\n+  def save_inventory_with_multi_findkey(rel_type, association, parent, h, record_index, new_records, deletes)\n+    found = record_index.fetch(h)\n+\n+    if found.nil?\n+      found = association.build(h.except(:id))\n+      new_records << found\n+    else\n+      found.update_attributes!(h.except(:id, :type))\n+      deletes.delete(found) unless deletes.blank?\n+      unless parent.send(rel_type).include?(found)","path":"app/models/ems_refresh/save_inventory_helper.rb","position":37,"original_position":37,"commit_id":"f0c0b54e159fd173f8cd2bc804b31ea00fb70c90","original_commit_id":"f0c0b54e159fd173f8cd2bc804b31ea00fb70c90","user":{"login":"pkliczewski","id":1384786,"avatar_url":"https://avatars.githubusercontent.com/u/1384786?v=3","gravatar_id":"","url":"https://api.github.com/users/pkliczewski","html_url":"https://github.com/pkliczewski","followers_url":"https://api.github.com/users/pkliczewski/followers","following_url":"https://api.github.com/users/pkliczewski/following{/other_user}","gists_url":"https://api.github.com/users/pkliczewski/gists{/gist_id}","starred_url":"https://api.github.com/users/pkliczewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkliczewski/subscriptions","organizations_url":"https://api.github.com/users/pkliczewski/orgs","repos_url":"https://api.github.com/users/pkliczewski/repos","events_url":"https://api.github.com/users/pkliczewski/events{/privacy}","received_events_url":"https://api.github.com/users/pkliczewski/received_events","type":"User","site_admin":false},"body":"It is not happening there because we use where to fetch collection of disks.","created_at":"2016-11-08T18:18:01Z","updated_at":"2016-11-08T18:18:01Z","html_url":"https://github.com/ManageIQ/manageiq/pull/12079#discussion_r87050581","pull_request_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/12079","_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments/87050581"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/12079#discussion_r87050581"},"pull_request":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/12079"}}},"pull_request":{"url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/12079","id":90213027,"html_url":"https://github.com/ManageIQ/manageiq/pull/12079","diff_url":"https://github.com/ManageIQ/manageiq/pull/12079.diff","patch_url":"https://github.com/ManageIQ/manageiq/pull/12079.patch","issue_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/12079","number":12079,"state":"open","locked":false,"title":"Remove vm without disks","user":{"login":"pkliczewski","id":1384786,"avatar_url":"https://avatars.githubusercontent.com/u/1384786?v=3","gravatar_id":"","url":"https://api.github.com/users/pkliczewski","html_url":"https://github.com/pkliczewski","followers_url":"https://api.github.com/users/pkliczewski/followers","following_url":"https://api.github.com/users/pkliczewski/following{/other_user}","gists_url":"https://api.github.com/users/pkliczewski/gists{/gist_id}","starred_url":"https://api.github.com/users/pkliczewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkliczewski/subscriptions","organizations_url":"https://api.github.com/users/pkliczewski/orgs","repos_url":"https://api.github.com/users/pkliczewski/repos","events_url":"https://api.github.com/users/pkliczewski/events{/privacy}","received_events_url":"https://api.github.com/users/pkliczewski/received_events","type":"User","site_admin":false},"body":"We need to detect whether the disks were removed or not together with a vm. Based on this decision we need to make a decision whether to disconnect storage from the vm.\n\nThis PR fixes:\nhttps://bugzilla.redhat.com/1334949\n","created_at":"2016-10-20T14:34:38Z","updated_at":"2016-11-08T18:18:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"97ab0567ef7137604cdc444903106378e3ae2739","assignee":{"login":"durandom","id":161888,"avatar_url":"https://avatars.githubusercontent.com/u/161888?v=3","gravatar_id":"","url":"https://api.github.com/users/durandom","html_url":"https://github.com/durandom","followers_url":"https://api.github.com/users/durandom/followers","following_url":"https://api.github.com/users/durandom/following{/other_user}","gists_url":"https://api.github.com/users/durandom/gists{/gist_id}","starred_url":"https://api.github.com/users/durandom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durandom/subscriptions","organizations_url":"https://api.github.com/users/durandom/orgs","repos_url":"https://api.github.com/users/durandom/repos","events_url":"https://api.github.com/users/durandom/events{/privacy}","received_events_url":"https://api.github.com/users/durandom/received_events","type":"User","site_admin":false},"assignees":[{"login":"durandom","id":161888,"avatar_url":"https://avatars.githubusercontent.com/u/161888?v=3","gravatar_id":"","url":"https://api.github.com/users/durandom","html_url":"https://github.com/durandom","followers_url":"https://api.github.com/users/durandom/followers","following_url":"https://api.github.com/users/durandom/following{/other_user}","gists_url":"https://api.github.com/users/durandom/gists{/gist_id}","starred_url":"https://api.github.com/users/durandom/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/durandom/subscriptions","organizations_url":"https://api.github.com/users/durandom/orgs","repos_url":"https://api.github.com/users/durandom/repos","events_url":"https://api.github.com/users/durandom/events{/privacy}","received_events_url":"https://api.github.com/users/durandom/received_events","type":"User","site_admin":false},{"login":"agrare","id":12851112,"avatar_url":"https://avatars.githubusercontent.com/u/12851112?v=3","gravatar_id":"","url":"https://api.github.com/users/agrare","html_url":"https://github.com/agrare","followers_url":"https://api.github.com/users/agrare/followers","following_url":"https://api.github.com/users/agrare/following{/other_user}","gists_url":"https://api.github.com/users/agrare/gists{/gist_id}","starred_url":"https://api.github.com/users/agrare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/agrare/subscriptions","organizations_url":"https://api.github.com/users/agrare/orgs","repos_url":"https://api.github.com/users/agrare/repos","events_url":"https://api.github.com/users/agrare/events{/privacy}","received_events_url":"https://api.github.com/users/agrare/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/12079/commits","review_comments_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/12079/comments","review_comment_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/12079/comments","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq/statuses/f0c0b54e159fd173f8cd2bc804b31ea00fb70c90","head":{"label":"pkliczewski:vm_remove_target","ref":"vm_remove_target","sha":"f0c0b54e159fd173f8cd2bc804b31ea00fb70c90","user":{"login":"pkliczewski","id":1384786,"avatar_url":"https://avatars.githubusercontent.com/u/1384786?v=3","gravatar_id":"","url":"https://api.github.com/users/pkliczewski","html_url":"https://github.com/pkliczewski","followers_url":"https://api.github.com/users/pkliczewski/followers","following_url":"https://api.github.com/users/pkliczewski/following{/other_user}","gists_url":"https://api.github.com/users/pkliczewski/gists{/gist_id}","starred_url":"https://api.github.com/users/pkliczewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkliczewski/subscriptions","organizations_url":"https://api.github.com/users/pkliczewski/orgs","repos_url":"https://api.github.com/users/pkliczewski/repos","events_url":"https://api.github.com/users/pkliczewski/events{/privacy}","received_events_url":"https://api.github.com/users/pkliczewski/received_events","type":"User","site_admin":false},"repo":{"id":52615153,"name":"manageiq","full_name":"pkliczewski/manageiq","owner":{"login":"pkliczewski","id":1384786,"avatar_url":"https://avatars.githubusercontent.com/u/1384786?v=3","gravatar_id":"","url":"https://api.github.com/users/pkliczewski","html_url":"https://github.com/pkliczewski","followers_url":"https://api.github.com/users/pkliczewski/followers","following_url":"https://api.github.com/users/pkliczewski/following{/other_user}","gists_url":"https://api.github.com/users/pkliczewski/gists{/gist_id}","starred_url":"https://api.github.com/users/pkliczewski/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pkliczewski/subscriptions","organizations_url":"https://api.github.com/users/pkliczewski/orgs","repos_url":"https://api.github.com/users/pkliczewski/repos","events_url":"https://api.github.com/users/pkliczewski/events{/privacy}","received_events_url":"https://api.github.com/users/pkliczewski/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/pkliczewski/manageiq","description":"ManageIQ Cloud Management Platform","fork":true,"url":"https://api.github.com/repos/pkliczewski/manageiq","forks_url":"https://api.github.com/repos/pkliczewski/manageiq/forks","keys_url":"https://api.github.com/repos/pkliczewski/manageiq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pkliczewski/manageiq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pkliczewski/manageiq/teams","hooks_url":"https://api.github.com/repos/pkliczewski/manageiq/hooks","issue_events_url":"https://api.github.com/repos/pkliczewski/manageiq/issues/events{/number}","events_url":"https://api.github.com/repos/pkliczewski/manageiq/events","assignees_url":"https://api.github.com/repos/pkliczewski/manageiq/assignees{/user}","branches_url":"https://api.github.com/repos/pkliczewski/manageiq/branches{/branch}","tags_url":"https://api.github.com/repos/pkliczewski/manageiq/tags","blobs_url":"https://api.github.com/repos/pkliczewski/manageiq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pkliczewski/manageiq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pkliczewski/manageiq/git/refs{/sha}","trees_url":"https://api.github.com/repos/pkliczewski/manageiq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pkliczewski/manageiq/statuses/{sha}","languages_url":"https://api.github.com/repos/pkliczewski/manageiq/languages","stargazers_url":"https://api.github.com/repos/pkliczewski/manageiq/stargazers","contributors_url":"https://api.github.com/repos/pkliczewski/manageiq/contributors","subscribers_url":"https://api.github.com/repos/pkliczewski/manageiq/subscribers","subscription_url":"https://api.github.com/repos/pkliczewski/manageiq/subscription","commits_url":"https://api.github.com/repos/pkliczewski/manageiq/commits{/sha}","git_commits_url":"https://api.github.com/repos/pkliczewski/manageiq/git/commits{/sha}","comments_url":"https://api.github.com/repos/pkliczewski/manageiq/comments{/number}","issue_comment_url":"https://api.github.com/repos/pkliczewski/manageiq/issues/comments{/number}","contents_url":"https://api.github.com/repos/pkliczewski/manageiq/contents/{+path}","compare_url":"https://api.github.com/repos/pkliczewski/manageiq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pkliczewski/manageiq/merges","archive_url":"https://api.github.com/repos/pkliczewski/manageiq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pkliczewski/manageiq/downloads","issues_url":"https://api.github.com/repos/pkliczewski/manageiq/issues{/number}","pulls_url":"https://api.github.com/repos/pkliczewski/manageiq/pulls{/number}","milestones_url":"https://api.github.com/repos/pkliczewski/manageiq/milestones{/number}","notifications_url":"https://api.github.com/repos/pkliczewski/manageiq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pkliczewski/manageiq/labels{/name}","releases_url":"https://api.github.com/repos/pkliczewski/manageiq/releases{/id}","deployments_url":"https://api.github.com/repos/pkliczewski/manageiq/deployments","created_at":"2016-02-26T15:55:23Z","updated_at":"2016-02-26T15:55:40Z","pushed_at":"2016-11-04T15:57:03Z","git_url":"git://github.com/pkliczewski/manageiq.git","ssh_url":"git@github.com:pkliczewski/manageiq.git","clone_url":"https://github.com/pkliczewski/manageiq.git","svn_url":"https://github.com/pkliczewski/manageiq","homepage":"manageiq.org","size":170733,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ManageIQ:master","ref":"master","sha":"7b18c06cc2bf93f9dca349a9eabbfa7b7281e72d","user":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"repo":{"id":20789757,"name":"manageiq","full_name":"ManageIQ/manageiq","owner":{"login":"ManageIQ","id":1125575,"avatar_url":"https://avatars.githubusercontent.com/u/1125575?v=3","gravatar_id":"","url":"https://api.github.com/users/ManageIQ","html_url":"https://github.com/ManageIQ","followers_url":"https://api.github.com/users/ManageIQ/followers","following_url":"https://api.github.com/users/ManageIQ/following{/other_user}","gists_url":"https://api.github.com/users/ManageIQ/gists{/gist_id}","starred_url":"https://api.github.com/users/ManageIQ/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ManageIQ/subscriptions","organizations_url":"https://api.github.com/users/ManageIQ/orgs","repos_url":"https://api.github.com/users/ManageIQ/repos","events_url":"https://api.github.com/users/ManageIQ/events{/privacy}","received_events_url":"https://api.github.com/users/ManageIQ/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ManageIQ/manageiq","description":"ManageIQ Open-Source Management Platform","fork":false,"url":"https://api.github.com/repos/ManageIQ/manageiq","forks_url":"https://api.github.com/repos/ManageIQ/manageiq/forks","keys_url":"https://api.github.com/repos/ManageIQ/manageiq/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ManageIQ/manageiq/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ManageIQ/manageiq/teams","hooks_url":"https://api.github.com/repos/ManageIQ/manageiq/hooks","issue_events_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/events{/number}","events_url":"https://api.github.com/repos/ManageIQ/manageiq/events","assignees_url":"https://api.github.com/repos/ManageIQ/manageiq/assignees{/user}","branches_url":"https://api.github.com/repos/ManageIQ/manageiq/branches{/branch}","tags_url":"https://api.github.com/repos/ManageIQ/manageiq/tags","blobs_url":"https://api.github.com/repos/ManageIQ/manageiq/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ManageIQ/manageiq/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ManageIQ/manageiq/git/refs{/sha}","trees_url":"https://api.github.com/repos/ManageIQ/manageiq/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ManageIQ/manageiq/statuses/{sha}","languages_url":"https://api.github.com/repos/ManageIQ/manageiq/languages","stargazers_url":"https://api.github.com/repos/ManageIQ/manageiq/stargazers","contributors_url":"https://api.github.com/repos/ManageIQ/manageiq/contributors","subscribers_url":"https://api.github.com/repos/ManageIQ/manageiq/subscribers","subscription_url":"https://api.github.com/repos/ManageIQ/manageiq/subscription","commits_url":"https://api.github.com/repos/ManageIQ/manageiq/commits{/sha}","git_commits_url":"https://api.github.com/repos/ManageIQ/manageiq/git/commits{/sha}","comments_url":"https://api.github.com/repos/ManageIQ/manageiq/comments{/number}","issue_comment_url":"https://api.github.com/repos/ManageIQ/manageiq/issues/comments{/number}","contents_url":"https://api.github.com/repos/ManageIQ/manageiq/contents/{+path}","compare_url":"https://api.github.com/repos/ManageIQ/manageiq/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ManageIQ/manageiq/merges","archive_url":"https://api.github.com/repos/ManageIQ/manageiq/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ManageIQ/manageiq/downloads","issues_url":"https://api.github.com/repos/ManageIQ/manageiq/issues{/number}","pulls_url":"https://api.github.com/repos/ManageIQ/manageiq/pulls{/number}","milestones_url":"https://api.github.com/repos/ManageIQ/manageiq/milestones{/number}","notifications_url":"https://api.github.com/repos/ManageIQ/manageiq/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ManageIQ/manageiq/labels{/name}","releases_url":"https://api.github.com/repos/ManageIQ/manageiq/releases{/id}","deployments_url":"https://api.github.com/repos/ManageIQ/manageiq/deployments","created_at":"2014-06-13T02:31:26Z","updated_at":"2016-11-05T06:20:46Z","pushed_at":"2016-11-08T18:13:57Z","git_url":"git://github.com/ManageIQ/manageiq.git","ssh_url":"git@github.com:ManageIQ/manageiq.git","clone_url":"https://github.com/ManageIQ/manageiq.git","svn_url":"https://github.com/ManageIQ/manageiq","homepage":"manageiq.org","size":219490,"stargazers_count":347,"watchers_count":347,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":377,"mirror_url":null,"open_issues_count":908,"forks":377,"open_issues":908,"watchers":347,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/12079"},"html":{"href":"https://github.com/ManageIQ/manageiq/pull/12079"},"issue":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/12079"},"comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/issues/12079/comments"},"review_comments":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/12079/comments"},"review_comment":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ManageIQ/manageiq/pulls/12079/commits"},"statuses":{"href":"https://api.github.com/repos/ManageIQ/manageiq/statuses/f0c0b54e159fd173f8cd2bc804b31ea00fb70c90"}}}}
{"actor":{"display_login":"pkliczewski"}}