{"action":"created","comment":{"url":"https://api.github.com/repos/theforeman/foreman/pulls/comments/67340894","id":67340894,"diff_hunk":"@@ -1,24 +1,11 @@\n desc 'Fix cached counters by reseting them to the correct count, in case they got corrupted somehow'\n task :fix_cached_counters => :environment do\n   puts \"Correcting cached counters: (this may take a few minutes)\"\n-  [ Architecture, Environment, Operatingsystem, Realm].each do |cl|\n-    cl.unscoped.all.each{|el| cl.reset_counters(el.id, :hosts, :hostgroups)}\n-    puts \"#{cl} corrected\"\n-  end\n-  Domain.all.each do |el|\n-    Domain.reset_counters(el.id, :hostgroups)\n-    el.update_attribute('total_hosts', Nic::Base.primary.where(:domain_id => el.id).count)\n-  end\n-  puts \"Domains corrected\"\n   Puppetclass.all.each{|el| Puppetclass.reset_counters(el.id, :lookup_keys)}\n   puts \"Puppetclass corrected\"\n-  Model.all.each{|el| Model.reset_counters(el.id, :hosts)}\n-  puts \"Model corrected\"\n   ConfigGroup.all.each{|el| ConfigGroup.reset_counters(el.id, :config_group_classes)}\n   puts \"ConfigGroup corrected\"\n   LookupKey.all.each{|el| LookupKey.reset_counters(el.id, :lookup_values)}\n   puts \"LookupKey corrected\"\n-  Hostgroup.all.each{|el| Hostgroup.reset_counters(el.id, :hosts)}\n-  puts \"Hostgroup corrected\"\n end","path":"lib/tasks/fix_cached_counters.rake","position":23,"original_position":23,"commit_id":"7c0e3ec5cc7817af34056454824df36c54760ffd","original_commit_id":"7c0e3ec5cc7817af34056454824df36c54760ffd","user":{"login":"lzap","id":49752,"avatar_url":"https://avatars.githubusercontent.com/u/49752?v=3","gravatar_id":"","url":"https://api.github.com/users/lzap","html_url":"https://github.com/lzap","followers_url":"https://api.github.com/users/lzap/followers","following_url":"https://api.github.com/users/lzap/following{/other_user}","gists_url":"https://api.github.com/users/lzap/gists{/gist_id}","starred_url":"https://api.github.com/users/lzap/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lzap/subscriptions","organizations_url":"https://api.github.com/users/lzap/orgs","repos_url":"https://api.github.com/users/lzap/repos","events_url":"https://api.github.com/users/lzap/events{/privacy}","received_events_url":"https://api.github.com/users/lzap/received_events","type":"User","site_admin":false},"body":"Are you leaving some counters on purpose?","created_at":"2016-06-16T13:12:42Z","updated_at":"2016-06-16T13:12:42Z","html_url":"https://github.com/theforeman/foreman/pull/3596#discussion_r67340894","pull_request_url":"https://api.github.com/repos/theforeman/foreman/pulls/3596","_links":{"self":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/comments/67340894"},"html":{"href":"https://github.com/theforeman/foreman/pull/3596#discussion_r67340894"},"pull_request":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/3596"}}},"pull_request":{"url":"https://api.github.com/repos/theforeman/foreman/pulls/3596","id":74071792,"html_url":"https://github.com/theforeman/foreman/pull/3596","diff_url":"https://github.com/theforeman/foreman/pull/3596.diff","patch_url":"https://github.com/theforeman/foreman/pull/3596.patch","issue_url":"https://api.github.com/repos/theforeman/foreman/issues/3596","number":3596,"state":"open","locked":false,"title":"Fixes #12193 - Stop using counter_cache for host[group] counts","user":{"login":"tbrisker","id":1540531,"avatar_url":"https://avatars.githubusercontent.com/u/1540531?v=3","gravatar_id":"","url":"https://api.github.com/users/tbrisker","html_url":"https://github.com/tbrisker","followers_url":"https://api.github.com/users/tbrisker/followers","following_url":"https://api.github.com/users/tbrisker/following{/other_user}","gists_url":"https://api.github.com/users/tbrisker/gists{/gist_id}","starred_url":"https://api.github.com/users/tbrisker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbrisker/subscriptions","organizations_url":"https://api.github.com/users/tbrisker/orgs","repos_url":"https://api.github.com/users/tbrisker/repos","events_url":"https://api.github.com/users/tbrisker/events{/privacy}","received_events_url":"https://api.github.com/users/tbrisker/received_events","type":"User","site_admin":false},"body":"This is aimed to prevent deadlocks caused by Rails' implementation of\r\ncounter_cache that is hit when multiple hosts are created or updated at\r\nthe same time. An added benefit is that the counters will now display\r\nthe number of hosts scoped to the current taxonomy and authorized for\r\nthe user to see. It also removes a lot of code used to workaround\r\nvarious counter_cache issues.\r\nThe downsides are that sorting and filtering based on host counts will\r\nno longer work, and that page load times may increase for pages\r\ncontaining host counters, such as enviroments index.","created_at":"2016-06-16T12:29:24Z","updated_at":"2016-06-16T13:12:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1230eef0c50696139dc309126daa67978ad1497b","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/theforeman/foreman/pulls/3596/commits","review_comments_url":"https://api.github.com/repos/theforeman/foreman/pulls/3596/comments","review_comment_url":"https://api.github.com/repos/theforeman/foreman/pulls/comments{/number}","comments_url":"https://api.github.com/repos/theforeman/foreman/issues/3596/comments","statuses_url":"https://api.github.com/repos/theforeman/foreman/statuses/7c0e3ec5cc7817af34056454824df36c54760ffd","head":{"label":"tbrisker:12193","ref":"12193","sha":"7c0e3ec5cc7817af34056454824df36c54760ffd","user":{"login":"tbrisker","id":1540531,"avatar_url":"https://avatars.githubusercontent.com/u/1540531?v=3","gravatar_id":"","url":"https://api.github.com/users/tbrisker","html_url":"https://github.com/tbrisker","followers_url":"https://api.github.com/users/tbrisker/followers","following_url":"https://api.github.com/users/tbrisker/following{/other_user}","gists_url":"https://api.github.com/users/tbrisker/gists{/gist_id}","starred_url":"https://api.github.com/users/tbrisker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbrisker/subscriptions","organizations_url":"https://api.github.com/users/tbrisker/orgs","repos_url":"https://api.github.com/users/tbrisker/repos","events_url":"https://api.github.com/users/tbrisker/events{/privacy}","received_events_url":"https://api.github.com/users/tbrisker/received_events","type":"User","site_admin":false},"repo":{"id":22373475,"name":"foreman","full_name":"tbrisker/foreman","owner":{"login":"tbrisker","id":1540531,"avatar_url":"https://avatars.githubusercontent.com/u/1540531?v=3","gravatar_id":"","url":"https://api.github.com/users/tbrisker","html_url":"https://github.com/tbrisker","followers_url":"https://api.github.com/users/tbrisker/followers","following_url":"https://api.github.com/users/tbrisker/following{/other_user}","gists_url":"https://api.github.com/users/tbrisker/gists{/gist_id}","starred_url":"https://api.github.com/users/tbrisker/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tbrisker/subscriptions","organizations_url":"https://api.github.com/users/tbrisker/orgs","repos_url":"https://api.github.com/users/tbrisker/repos","events_url":"https://api.github.com/users/tbrisker/events{/privacy}","received_events_url":"https://api.github.com/users/tbrisker/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tbrisker/foreman","description":"an application that automates the lifecycle of servers ","fork":true,"url":"https://api.github.com/repos/tbrisker/foreman","forks_url":"https://api.github.com/repos/tbrisker/foreman/forks","keys_url":"https://api.github.com/repos/tbrisker/foreman/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tbrisker/foreman/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tbrisker/foreman/teams","hooks_url":"https://api.github.com/repos/tbrisker/foreman/hooks","issue_events_url":"https://api.github.com/repos/tbrisker/foreman/issues/events{/number}","events_url":"https://api.github.com/repos/tbrisker/foreman/events","assignees_url":"https://api.github.com/repos/tbrisker/foreman/assignees{/user}","branches_url":"https://api.github.com/repos/tbrisker/foreman/branches{/branch}","tags_url":"https://api.github.com/repos/tbrisker/foreman/tags","blobs_url":"https://api.github.com/repos/tbrisker/foreman/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tbrisker/foreman/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tbrisker/foreman/git/refs{/sha}","trees_url":"https://api.github.com/repos/tbrisker/foreman/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tbrisker/foreman/statuses/{sha}","languages_url":"https://api.github.com/repos/tbrisker/foreman/languages","stargazers_url":"https://api.github.com/repos/tbrisker/foreman/stargazers","contributors_url":"https://api.github.com/repos/tbrisker/foreman/contributors","subscribers_url":"https://api.github.com/repos/tbrisker/foreman/subscribers","subscription_url":"https://api.github.com/repos/tbrisker/foreman/subscription","commits_url":"https://api.github.com/repos/tbrisker/foreman/commits{/sha}","git_commits_url":"https://api.github.com/repos/tbrisker/foreman/git/commits{/sha}","comments_url":"https://api.github.com/repos/tbrisker/foreman/comments{/number}","issue_comment_url":"https://api.github.com/repos/tbrisker/foreman/issues/comments{/number}","contents_url":"https://api.github.com/repos/tbrisker/foreman/contents/{+path}","compare_url":"https://api.github.com/repos/tbrisker/foreman/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tbrisker/foreman/merges","archive_url":"https://api.github.com/repos/tbrisker/foreman/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tbrisker/foreman/downloads","issues_url":"https://api.github.com/repos/tbrisker/foreman/issues{/number}","pulls_url":"https://api.github.com/repos/tbrisker/foreman/pulls{/number}","milestones_url":"https://api.github.com/repos/tbrisker/foreman/milestones{/number}","notifications_url":"https://api.github.com/repos/tbrisker/foreman/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tbrisker/foreman/labels{/name}","releases_url":"https://api.github.com/repos/tbrisker/foreman/releases{/id}","deployments_url":"https://api.github.com/repos/tbrisker/foreman/deployments","created_at":"2014-07-29T08:48:53Z","updated_at":"2016-01-11T13:37:29Z","pushed_at":"2016-06-16T13:07:06Z","git_url":"git://github.com/tbrisker/foreman.git","ssh_url":"git@github.com:tbrisker/foreman.git","clone_url":"https://github.com/tbrisker/foreman.git","svn_url":"https://github.com/tbrisker/foreman","homepage":"http://theforeman.org","size":37163,"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":"a45a87fe36ceab3c643955867356dc0f97dbe193","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-06-15T23:28:06Z","pushed_at":"2016-06-16T13:07:07Z","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":69662,"stargazers_count":1030,"watchers_count":1030,"language":"Ruby","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":527,"mirror_url":null,"open_issues_count":77,"forks":527,"open_issues":77,"watchers":1030,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/3596"},"html":{"href":"https://github.com/theforeman/foreman/pull/3596"},"issue":{"href":"https://api.github.com/repos/theforeman/foreman/issues/3596"},"comments":{"href":"https://api.github.com/repos/theforeman/foreman/issues/3596/comments"},"review_comments":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/3596/comments"},"review_comment":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/theforeman/foreman/pulls/3596/commits"},"statuses":{"href":"https://api.github.com/repos/theforeman/foreman/statuses/7c0e3ec5cc7817af34056454824df36c54760ffd"}}}}
{"actor":{"display_login":"lzap"}}