{"action":"created","comment":{"url":"https://api.github.com/repos/theforeman/foreman/pulls/comments/60884509","id":60884509,"diff_hunk":"@@ -69,8 +69,11 @@ def add_new_facts\n       method          = host.new_record? ? :build : :create!\n       fact_names      = fact_name_class.group(:name).maximum(:id)\n       facts_to_create.each do |name|\n-        host.fact_values.send(method, :value => facts[name],\n+        if name != \"_timestamp\" ","path":"app/services/fact_importer.rb","position":5,"original_position":5,"commit_id":"768014178c647d67a0ed7801d230444524391772","original_commit_id":"768014178c647d67a0ed7801d230444524391772","user":{"login":"ares","id":109773,"avatar_url":"https://avatars.githubusercontent.com/u/109773?v=3","gravatar_id":"","url":"https://api.github.com/users/ares","html_url":"https://github.com/ares","followers_url":"https://api.github.com/users/ares/followers","following_url":"https://api.github.com/users/ares/following{/other_user}","gists_url":"https://api.github.com/users/ares/gists{/gist_id}","starred_url":"https://api.github.com/users/ares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ares/subscriptions","organizations_url":"https://api.github.com/users/ares/orgs","repos_url":"https://api.github.com/users/ares/repos","events_url":"https://api.github.com/users/ares/events{/privacy}","received_events_url":"https://api.github.com/users/ares/received_events","type":"User","site_admin":false},"body":"maybe you could avoid this condition by removing this fact on first line of the method, result would look like this\r\n\r\n```ruby\r\n  def add_new_facts\r\n    facts_to_create = facts.keys - db_facts.keys - [ '_timestamp' ]\r\n    # if the host does not exists yet, we don't have an host_id to use the fact_values table.\r\n    if facts_to_create.present?\r\n      method          = host.new_record? ? :build : :create!\r\n      fact_names      = fact_name_class.group(:name).maximum(:id)\r\n      facts_to_create.each do |name|\r\n        logger.debug(\"#{self.class.to_s}#facts_to_create #{method} new fact with name '#{name}'\")\r\n        host.fact_values.send(method, :value => facts[name],\r\n                              :fact_name_id  => fact_names[name] || fact_name_class.create!(:name => name).id)\r\n      end\r\n    end\r\n\r\n    @counters[:added] = facts_to_create.size\r\n    logger.debug(\"Merging facts for '#{host}': added #{@counters[:added]} facts\")\r\n  end\r\n```","created_at":"2016-04-25T09:25:23Z","updated_at":"2016-04-25T09:25:23Z","html_url":"https://github.com/theforeman/foreman/pull/3456#discussion_r60884509","pull_request_url":"https://api.github.com/repos/theforeman/foreman/pulls/3456","_links":{"self":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/comments/60884509"},"html":{"href":"https://github.com/theforeman/foreman/pull/3456#discussion_r60884509"},"pull_request":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/3456"}}},"pull_request":{"url":"https://api.github.com/repos/theforeman/foreman/pulls/3456","id":67557998,"html_url":"https://github.com/theforeman/foreman/pull/3456","diff_url":"https://github.com/theforeman/foreman/pull/3456.diff","patch_url":"https://github.com/theforeman/foreman/pull/3456.patch","issue_url":"https://api.github.com/repos/theforeman/foreman/issues/3456","number":3456,"state":"open","locked":false,"title":"Fixes #13819 _timestamp collision in facts_to_create","user":{"login":"mkbrown","id":10076016,"avatar_url":"https://avatars.githubusercontent.com/u/10076016?v=3","gravatar_id":"","url":"https://api.github.com/users/mkbrown","html_url":"https://github.com/mkbrown","followers_url":"https://api.github.com/users/mkbrown/followers","following_url":"https://api.github.com/users/mkbrown/following{/other_user}","gists_url":"https://api.github.com/users/mkbrown/gists{/gist_id}","starred_url":"https://api.github.com/users/mkbrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkbrown/subscriptions","organizations_url":"https://api.github.com/users/mkbrown/orgs","repos_url":"https://api.github.com/users/mkbrown/repos","events_url":"https://api.github.com/users/mkbrown/events{/privacy}","received_events_url":"https://api.github.com/users/mkbrown/received_events","type":"User","site_admin":false},"body":"Refs #14761, _timestamp already existing (and used) by Foreman, but Puppet versions < 4 may also submit.  Causes facts to fail to upload.  Requesting inclusion for Foreman 1.10.4","created_at":"2016-04-22T19:04:23Z","updated_at":"2016-04-25T09:25:23Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c7f33809955c0399f36a06ab4e346133a05250ac","assignee":{"login":"ares","id":109773,"avatar_url":"https://avatars.githubusercontent.com/u/109773?v=3","gravatar_id":"","url":"https://api.github.com/users/ares","html_url":"https://github.com/ares","followers_url":"https://api.github.com/users/ares/followers","following_url":"https://api.github.com/users/ares/following{/other_user}","gists_url":"https://api.github.com/users/ares/gists{/gist_id}","starred_url":"https://api.github.com/users/ares/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ares/subscriptions","organizations_url":"https://api.github.com/users/ares/orgs","repos_url":"https://api.github.com/users/ares/repos","events_url":"https://api.github.com/users/ares/events{/privacy}","received_events_url":"https://api.github.com/users/ares/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/theforeman/foreman/pulls/3456/commits","review_comments_url":"https://api.github.com/repos/theforeman/foreman/pulls/3456/comments","review_comment_url":"https://api.github.com/repos/theforeman/foreman/pulls/comments{/number}","comments_url":"https://api.github.com/repos/theforeman/foreman/issues/3456/comments","statuses_url":"https://api.github.com/repos/theforeman/foreman/statuses/768014178c647d67a0ed7801d230444524391772","head":{"label":"mkbrown:mkbrown-patch-13819","ref":"mkbrown-patch-13819","sha":"768014178c647d67a0ed7801d230444524391772","user":{"login":"mkbrown","id":10076016,"avatar_url":"https://avatars.githubusercontent.com/u/10076016?v=3","gravatar_id":"","url":"https://api.github.com/users/mkbrown","html_url":"https://github.com/mkbrown","followers_url":"https://api.github.com/users/mkbrown/followers","following_url":"https://api.github.com/users/mkbrown/following{/other_user}","gists_url":"https://api.github.com/users/mkbrown/gists{/gist_id}","starred_url":"https://api.github.com/users/mkbrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkbrown/subscriptions","organizations_url":"https://api.github.com/users/mkbrown/orgs","repos_url":"https://api.github.com/users/mkbrown/repos","events_url":"https://api.github.com/users/mkbrown/events{/privacy}","received_events_url":"https://api.github.com/users/mkbrown/received_events","type":"User","site_admin":false},"repo":{"id":56858219,"name":"foreman","full_name":"mkbrown/foreman","owner":{"login":"mkbrown","id":10076016,"avatar_url":"https://avatars.githubusercontent.com/u/10076016?v=3","gravatar_id":"","url":"https://api.github.com/users/mkbrown","html_url":"https://github.com/mkbrown","followers_url":"https://api.github.com/users/mkbrown/followers","following_url":"https://api.github.com/users/mkbrown/following{/other_user}","gists_url":"https://api.github.com/users/mkbrown/gists{/gist_id}","starred_url":"https://api.github.com/users/mkbrown/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mkbrown/subscriptions","organizations_url":"https://api.github.com/users/mkbrown/orgs","repos_url":"https://api.github.com/users/mkbrown/repos","events_url":"https://api.github.com/users/mkbrown/events{/privacy}","received_events_url":"https://api.github.com/users/mkbrown/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mkbrown/foreman","description":"an application that automates the lifecycle of servers ","fork":true,"url":"https://api.github.com/repos/mkbrown/foreman","forks_url":"https://api.github.com/repos/mkbrown/foreman/forks","keys_url":"https://api.github.com/repos/mkbrown/foreman/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mkbrown/foreman/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mkbrown/foreman/teams","hooks_url":"https://api.github.com/repos/mkbrown/foreman/hooks","issue_events_url":"https://api.github.com/repos/mkbrown/foreman/issues/events{/number}","events_url":"https://api.github.com/repos/mkbrown/foreman/events","assignees_url":"https://api.github.com/repos/mkbrown/foreman/assignees{/user}","branches_url":"https://api.github.com/repos/mkbrown/foreman/branches{/branch}","tags_url":"https://api.github.com/repos/mkbrown/foreman/tags","blobs_url":"https://api.github.com/repos/mkbrown/foreman/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mkbrown/foreman/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mkbrown/foreman/git/refs{/sha}","trees_url":"https://api.github.com/repos/mkbrown/foreman/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mkbrown/foreman/statuses/{sha}","languages_url":"https://api.github.com/repos/mkbrown/foreman/languages","stargazers_url":"https://api.github.com/repos/mkbrown/foreman/stargazers","contributors_url":"https://api.github.com/repos/mkbrown/foreman/contributors","subscribers_url":"https://api.github.com/repos/mkbrown/foreman/subscribers","subscription_url":"https://api.github.com/repos/mkbrown/foreman/subscription","commits_url":"https://api.github.com/repos/mkbrown/foreman/commits{/sha}","git_commits_url":"https://api.github.com/repos/mkbrown/foreman/git/commits{/sha}","comments_url":"https://api.github.com/repos/mkbrown/foreman/comments{/number}","issue_comment_url":"https://api.github.com/repos/mkbrown/foreman/issues/comments{/number}","contents_url":"https://api.github.com/repos/mkbrown/foreman/contents/{+path}","compare_url":"https://api.github.com/repos/mkbrown/foreman/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mkbrown/foreman/merges","archive_url":"https://api.github.com/repos/mkbrown/foreman/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mkbrown/foreman/downloads","issues_url":"https://api.github.com/repos/mkbrown/foreman/issues{/number}","pulls_url":"https://api.github.com/repos/mkbrown/foreman/pulls{/number}","milestones_url":"https://api.github.com/repos/mkbrown/foreman/milestones{/number}","notifications_url":"https://api.github.com/repos/mkbrown/foreman/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mkbrown/foreman/labels{/name}","releases_url":"https://api.github.com/repos/mkbrown/foreman/releases{/id}","deployments_url":"https://api.github.com/repos/mkbrown/foreman/deployments","created_at":"2016-04-22T13:42:52Z","updated_at":"2016-04-22T13:42:57Z","pushed_at":"2016-04-22T19:01:55Z","git_url":"git://github.com/mkbrown/foreman.git","ssh_url":"git@github.com:mkbrown/foreman.git","clone_url":"https://github.com/mkbrown/foreman.git","svn_url":"https://github.com/mkbrown/foreman","homepage":"http://theforeman.org","size":47300,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":false,"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":"develop"}},"base":{"label":"theforeman:develop","ref":"develop","sha":"3dab648c4cb38194fde156dac6756049e1e827d9","user":{"login":"theforeman","id":1439844,"avatar_url":"https://avatars.githubusercontent.com/u/1439844?v=3","gravatar_id":"","url":"https://api.github.com/users/theforeman","html_url":"https://github.com/theforeman","followers_url":"https://api.github.com/users/theforeman/followers","following_url":"https://api.github.com/users/theforeman/following{/other_user}","gists_url":"https://api.github.com/users/theforeman/gists{/gist_id}","starred_url":"https://api.github.com/users/theforeman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theforeman/subscriptions","organizations_url":"https://api.github.com/users/theforeman/orgs","repos_url":"https://api.github.com/users/theforeman/repos","events_url":"https://api.github.com/users/theforeman/events{/privacy}","received_events_url":"https://api.github.com/users/theforeman/received_events","type":"Organization","site_admin":false},"repo":{"id":258750,"name":"foreman","full_name":"theforeman/foreman","owner":{"login":"theforeman","id":1439844,"avatar_url":"https://avatars.githubusercontent.com/u/1439844?v=3","gravatar_id":"","url":"https://api.github.com/users/theforeman","html_url":"https://github.com/theforeman","followers_url":"https://api.github.com/users/theforeman/followers","following_url":"https://api.github.com/users/theforeman/following{/other_user}","gists_url":"https://api.github.com/users/theforeman/gists{/gist_id}","starred_url":"https://api.github.com/users/theforeman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/theforeman/subscriptions","organizations_url":"https://api.github.com/users/theforeman/orgs","repos_url":"https://api.github.com/users/theforeman/repos","events_url":"https://api.github.com/users/theforeman/events{/privacy}","received_events_url":"https://api.github.com/users/theforeman/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/theforeman/foreman","description":"an application that automates the lifecycle of servers ","fork":false,"url":"https://api.github.com/repos/theforeman/foreman","forks_url":"https://api.github.com/repos/theforeman/foreman/forks","keys_url":"https://api.github.com/repos/theforeman/foreman/keys{/key_id}","collaborators_url":"https://api.github.com/repos/theforeman/foreman/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/theforeman/foreman/teams","hooks_url":"https://api.github.com/repos/theforeman/foreman/hooks","issue_events_url":"https://api.github.com/repos/theforeman/foreman/issues/events{/number}","events_url":"https://api.github.com/repos/theforeman/foreman/events","assignees_url":"https://api.github.com/repos/theforeman/foreman/assignees{/user}","branches_url":"https://api.github.com/repos/theforeman/foreman/branches{/branch}","tags_url":"https://api.github.com/repos/theforeman/foreman/tags","blobs_url":"https://api.github.com/repos/theforeman/foreman/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/theforeman/foreman/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/theforeman/foreman/git/refs{/sha}","trees_url":"https://api.github.com/repos/theforeman/foreman/git/trees{/sha}","statuses_url":"https://api.github.com/repos/theforeman/foreman/statuses/{sha}","languages_url":"https://api.github.com/repos/theforeman/foreman/languages","stargazers_url":"https://api.github.com/repos/theforeman/foreman/stargazers","contributors_url":"https://api.github.com/repos/theforeman/foreman/contributors","subscribers_url":"https://api.github.com/repos/theforeman/foreman/subscribers","subscription_url":"https://api.github.com/repos/theforeman/foreman/subscription","commits_url":"https://api.github.com/repos/theforeman/foreman/commits{/sha}","git_commits_url":"https://api.github.com/repos/theforeman/foreman/git/commits{/sha}","comments_url":"https://api.github.com/repos/theforeman/foreman/comments{/number}","issue_comment_url":"https://api.github.com/repos/theforeman/foreman/issues/comments{/number}","contents_url":"https://api.github.com/repos/theforeman/foreman/contents/{+path}","compare_url":"https://api.github.com/repos/theforeman/foreman/compare/{base}...{head}","merges_url":"https://api.github.com/repos/theforeman/foreman/merges","archive_url":"https://api.github.com/repos/theforeman/foreman/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/theforeman/foreman/downloads","issues_url":"https://api.github.com/repos/theforeman/foreman/issues{/number}","pulls_url":"https://api.github.com/repos/theforeman/foreman/pulls{/number}","milestones_url":"https://api.github.com/repos/theforeman/foreman/milestones{/number}","notifications_url":"https://api.github.com/repos/theforeman/foreman/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/theforeman/foreman/labels{/name}","releases_url":"https://api.github.com/repos/theforeman/foreman/releases{/id}","deployments_url":"https://api.github.com/repos/theforeman/foreman/deployments","created_at":"2009-07-23T15:07:00Z","updated_at":"2016-04-23T15:05:28Z","pushed_at":"2016-04-25T09:12:26Z","git_url":"git://github.com/theforeman/foreman.git","ssh_url":"git@github.com:theforeman/foreman.git","clone_url":"https://github.com/theforeman/foreman.git","svn_url":"https://github.com/theforeman/foreman","homepage":"http://theforeman.org","size":65225,"stargazers_count":1002,"watchers_count":1002,"language":"Ruby","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":508,"mirror_url":null,"open_issues_count":74,"forks":508,"open_issues":74,"watchers":1002,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/3456"},"html":{"href":"https://github.com/theforeman/foreman/pull/3456"},"issue":{"href":"https://api.github.com/repos/theforeman/foreman/issues/3456"},"comments":{"href":"https://api.github.com/repos/theforeman/foreman/issues/3456/comments"},"review_comments":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/3456/comments"},"review_comment":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/3456/commits"},"statuses":{"href":"https://api.github.com/repos/theforeman/foreman/statuses/768014178c647d67a0ed7801d230444524391772"}}}}