{"action":"created","comment":{"url":"https://api.github.com/repos/spree/spree/pulls/comments/25086177","id":25086177,"diff_hunk":"@@ -0,0 +1,10 @@\n+class AddTotalOnHandToSpreeProducts < ActiveRecord::Migration\n+  def change\n+    add_column :spree_products, :count_on_hand, :integer, null: false, default: 0\n+  end\n+\n+  # seed the counts\n+  Spree::Variant.all.each { |v| v.update_counter_cache }\n+  Spree::Product.all.each { |v| v.update_counter_cache }","path":"core/db/migrate/20150220155706_add_total_on_hand_to_spree_products.rb","position":8,"original_position":8,"commit_id":"5c7be7922d5576298487346e8e2da45d975f076d","original_commit_id":"5c7be7922d5576298487346e8e2da45d975f076d","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Pass `&:update_counter_cache` as an argument to `each` instead of a block.","created_at":"2015-02-20T17:27:35Z","updated_at":"2015-02-20T17:27:35Z","html_url":"https://github.com/spree/spree/pull/6066#discussion_r25086177","pull_request_url":"https://api.github.com/repos/spree/spree/pulls/6066","_links":{"self":{"href":"https://api.github.com/repos/spree/spree/pulls/comments/25086177"},"html":{"href":"https://github.com/spree/spree/pull/6066#discussion_r25086177"},"pull_request":{"href":"https://api.github.com/repos/spree/spree/pulls/6066"}}},"pull_request":{"url":"https://api.github.com/repos/spree/spree/pulls/6066","id":29566981,"html_url":"https://github.com/spree/spree/pull/6066","diff_url":"https://github.com/spree/spree/pull/6066.diff","patch_url":"https://github.com/spree/spree/pull/6066.patch","issue_url":"https://api.github.com/repos/spree/spree/issues/6066","number":6066,"state":"open","locked":false,"title":"Adds count_on_hand to Spree::Variant to resolve n+1 queries","user":{"login":"bryanmtl","id":12205,"avatar_url":"https://avatars.githubusercontent.com/u/12205?v=3","gravatar_id":"","url":"https://api.github.com/users/bryanmtl","html_url":"https://github.com/bryanmtl","followers_url":"https://api.github.com/users/bryanmtl/followers","following_url":"https://api.github.com/users/bryanmtl/following{/other_user}","gists_url":"https://api.github.com/users/bryanmtl/gists{/gist_id}","starred_url":"https://api.github.com/users/bryanmtl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bryanmtl/subscriptions","organizations_url":"https://api.github.com/users/bryanmtl/orgs","repos_url":"https://api.github.com/users/bryanmtl/repos","events_url":"https://api.github.com/users/bryanmtl/events{/privacy}","received_events_url":"https://api.github.com/users/bryanmtl/received_events","type":"User","site_admin":false},"body":"This is a proof of concept, an attempt to resolve the n+1 query problem introduced by the stock items setup and as described [here](https://github.com/spree/spree/issues/5971). This approach should maintain backwards compatibility for stores that don't track inventory. \r\n\r\nFurther work should be done to optimize when the counter cache gets recomputed (ideally in the background).","created_at":"2015-02-18T21:53:41Z","updated_at":"2015-02-20T17:27:35Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5d5dbade28faa8cc2f13e44a7b95a4ce408232e5","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/spree/spree/pulls/6066/commits","review_comments_url":"https://api.github.com/repos/spree/spree/pulls/6066/comments","review_comment_url":"https://api.github.com/repos/spree/spree/pulls/comments/{number}","comments_url":"https://api.github.com/repos/spree/spree/issues/6066/comments","statuses_url":"https://api.github.com/repos/spree/spree/statuses/5c7be7922d5576298487346e8e2da45d975f076d","head":{"label":"DynamoMTL:feature/total-on-hand-optimizations","ref":"feature/total-on-hand-optimizations","sha":"5c7be7922d5576298487346e8e2da45d975f076d","user":{"login":"DynamoMTL","id":543835,"avatar_url":"https://avatars.githubusercontent.com/u/543835?v=3","gravatar_id":"","url":"https://api.github.com/users/DynamoMTL","html_url":"https://github.com/DynamoMTL","followers_url":"https://api.github.com/users/DynamoMTL/followers","following_url":"https://api.github.com/users/DynamoMTL/following{/other_user}","gists_url":"https://api.github.com/users/DynamoMTL/gists{/gist_id}","starred_url":"https://api.github.com/users/DynamoMTL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DynamoMTL/subscriptions","organizations_url":"https://api.github.com/users/DynamoMTL/orgs","repos_url":"https://api.github.com/users/DynamoMTL/repos","events_url":"https://api.github.com/users/DynamoMTL/events{/privacy}","received_events_url":"https://api.github.com/users/DynamoMTL/received_events","type":"Organization","site_admin":false},"repo":{"id":2845933,"name":"spree","full_name":"DynamoMTL/spree","owner":{"login":"DynamoMTL","id":543835,"avatar_url":"https://avatars.githubusercontent.com/u/543835?v=3","gravatar_id":"","url":"https://api.github.com/users/DynamoMTL","html_url":"https://github.com/DynamoMTL","followers_url":"https://api.github.com/users/DynamoMTL/followers","following_url":"https://api.github.com/users/DynamoMTL/following{/other_user}","gists_url":"https://api.github.com/users/DynamoMTL/gists{/gist_id}","starred_url":"https://api.github.com/users/DynamoMTL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/DynamoMTL/subscriptions","organizations_url":"https://api.github.com/users/DynamoMTL/orgs","repos_url":"https://api.github.com/users/DynamoMTL/repos","events_url":"https://api.github.com/users/DynamoMTL/events{/privacy}","received_events_url":"https://api.github.com/users/DynamoMTL/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/DynamoMTL/spree","description":"Spree is a complete open source e-commerce solution for Ruby on Rails.","fork":true,"url":"https://api.github.com/repos/DynamoMTL/spree","forks_url":"https://api.github.com/repos/DynamoMTL/spree/forks","keys_url":"https://api.github.com/repos/DynamoMTL/spree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/DynamoMTL/spree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/DynamoMTL/spree/teams","hooks_url":"https://api.github.com/repos/DynamoMTL/spree/hooks","issue_events_url":"https://api.github.com/repos/DynamoMTL/spree/issues/events{/number}","events_url":"https://api.github.com/repos/DynamoMTL/spree/events","assignees_url":"https://api.github.com/repos/DynamoMTL/spree/assignees{/user}","branches_url":"https://api.github.com/repos/DynamoMTL/spree/branches{/branch}","tags_url":"https://api.github.com/repos/DynamoMTL/spree/tags","blobs_url":"https://api.github.com/repos/DynamoMTL/spree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/DynamoMTL/spree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/DynamoMTL/spree/git/refs{/sha}","trees_url":"https://api.github.com/repos/DynamoMTL/spree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/DynamoMTL/spree/statuses/{sha}","languages_url":"https://api.github.com/repos/DynamoMTL/spree/languages","stargazers_url":"https://api.github.com/repos/DynamoMTL/spree/stargazers","contributors_url":"https://api.github.com/repos/DynamoMTL/spree/contributors","subscribers_url":"https://api.github.com/repos/DynamoMTL/spree/subscribers","subscription_url":"https://api.github.com/repos/DynamoMTL/spree/subscription","commits_url":"https://api.github.com/repos/DynamoMTL/spree/commits{/sha}","git_commits_url":"https://api.github.com/repos/DynamoMTL/spree/git/commits{/sha}","comments_url":"https://api.github.com/repos/DynamoMTL/spree/comments{/number}","issue_comment_url":"https://api.github.com/repos/DynamoMTL/spree/issues/comments/{number}","contents_url":"https://api.github.com/repos/DynamoMTL/spree/contents/{+path}","compare_url":"https://api.github.com/repos/DynamoMTL/spree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/DynamoMTL/spree/merges","archive_url":"https://api.github.com/repos/DynamoMTL/spree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/DynamoMTL/spree/downloads","issues_url":"https://api.github.com/repos/DynamoMTL/spree/issues{/number}","pulls_url":"https://api.github.com/repos/DynamoMTL/spree/pulls{/number}","milestones_url":"https://api.github.com/repos/DynamoMTL/spree/milestones{/number}","notifications_url":"https://api.github.com/repos/DynamoMTL/spree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/DynamoMTL/spree/labels{/name}","releases_url":"https://api.github.com/repos/DynamoMTL/spree/releases{/id}","created_at":"2011-11-24T20:51:58Z","updated_at":"2014-03-27T10:58:14Z","pushed_at":"2015-02-20T17:27:25Z","git_url":"git://github.com/DynamoMTL/spree.git","ssh_url":"git@github.com:DynamoMTL/spree.git","clone_url":"https://github.com/DynamoMTL/spree.git","svn_url":"https://github.com/DynamoMTL/spree","homepage":"http://spreecommerce.com","size":61991,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"spree:2-4-stable","ref":"2-4-stable","sha":"152938fd666173c8514da73a9a7bddabb26df25a","user":{"login":"spree","id":56702,"avatar_url":"https://avatars.githubusercontent.com/u/56702?v=3","gravatar_id":"","url":"https://api.github.com/users/spree","html_url":"https://github.com/spree","followers_url":"https://api.github.com/users/spree/followers","following_url":"https://api.github.com/users/spree/following{/other_user}","gists_url":"https://api.github.com/users/spree/gists{/gist_id}","starred_url":"https://api.github.com/users/spree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spree/subscriptions","organizations_url":"https://api.github.com/users/spree/orgs","repos_url":"https://api.github.com/users/spree/repos","events_url":"https://api.github.com/users/spree/events{/privacy}","received_events_url":"https://api.github.com/users/spree/received_events","type":"Organization","site_admin":false},"repo":{"id":3314,"name":"spree","full_name":"spree/spree","owner":{"login":"spree","id":56702,"avatar_url":"https://avatars.githubusercontent.com/u/56702?v=3","gravatar_id":"","url":"https://api.github.com/users/spree","html_url":"https://github.com/spree","followers_url":"https://api.github.com/users/spree/followers","following_url":"https://api.github.com/users/spree/following{/other_user}","gists_url":"https://api.github.com/users/spree/gists{/gist_id}","starred_url":"https://api.github.com/users/spree/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/spree/subscriptions","organizations_url":"https://api.github.com/users/spree/orgs","repos_url":"https://api.github.com/users/spree/repos","events_url":"https://api.github.com/users/spree/events{/privacy}","received_events_url":"https://api.github.com/users/spree/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/spree/spree","description":"Spree is a complete open source e-commerce solution for Ruby on Rails.","fork":false,"url":"https://api.github.com/repos/spree/spree","forks_url":"https://api.github.com/repos/spree/spree/forks","keys_url":"https://api.github.com/repos/spree/spree/keys{/key_id}","collaborators_url":"https://api.github.com/repos/spree/spree/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/spree/spree/teams","hooks_url":"https://api.github.com/repos/spree/spree/hooks","issue_events_url":"https://api.github.com/repos/spree/spree/issues/events{/number}","events_url":"https://api.github.com/repos/spree/spree/events","assignees_url":"https://api.github.com/repos/spree/spree/assignees{/user}","branches_url":"https://api.github.com/repos/spree/spree/branches{/branch}","tags_url":"https://api.github.com/repos/spree/spree/tags","blobs_url":"https://api.github.com/repos/spree/spree/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/spree/spree/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/spree/spree/git/refs{/sha}","trees_url":"https://api.github.com/repos/spree/spree/git/trees{/sha}","statuses_url":"https://api.github.com/repos/spree/spree/statuses/{sha}","languages_url":"https://api.github.com/repos/spree/spree/languages","stargazers_url":"https://api.github.com/repos/spree/spree/stargazers","contributors_url":"https://api.github.com/repos/spree/spree/contributors","subscribers_url":"https://api.github.com/repos/spree/spree/subscribers","subscription_url":"https://api.github.com/repos/spree/spree/subscription","commits_url":"https://api.github.com/repos/spree/spree/commits{/sha}","git_commits_url":"https://api.github.com/repos/spree/spree/git/commits{/sha}","comments_url":"https://api.github.com/repos/spree/spree/comments{/number}","issue_comment_url":"https://api.github.com/repos/spree/spree/issues/comments/{number}","contents_url":"https://api.github.com/repos/spree/spree/contents/{+path}","compare_url":"https://api.github.com/repos/spree/spree/compare/{base}...{head}","merges_url":"https://api.github.com/repos/spree/spree/merges","archive_url":"https://api.github.com/repos/spree/spree/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/spree/spree/downloads","issues_url":"https://api.github.com/repos/spree/spree/issues{/number}","pulls_url":"https://api.github.com/repos/spree/spree/pulls{/number}","milestones_url":"https://api.github.com/repos/spree/spree/milestones{/number}","notifications_url":"https://api.github.com/repos/spree/spree/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/spree/spree/labels{/name}","releases_url":"https://api.github.com/repos/spree/spree/releases{/id}","created_at":"2008-03-10T14:45:35Z","updated_at":"2015-02-20T11:44:58Z","pushed_at":"2015-02-20T14:36:06Z","git_url":"git://github.com/spree/spree.git","ssh_url":"git@github.com:spree/spree.git","clone_url":"https://github.com/spree/spree.git","svn_url":"https://github.com/spree/spree","homepage":"http://spreecommerce.com","size":130951,"stargazers_count":5994,"watchers_count":5994,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2802,"mirror_url":null,"open_issues_count":91,"forks":2802,"open_issues":91,"watchers":5994,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/spree/spree/pulls/6066"},"html":{"href":"https://github.com/spree/spree/pull/6066"},"issue":{"href":"https://api.github.com/repos/spree/spree/issues/6066"},"comments":{"href":"https://api.github.com/repos/spree/spree/issues/6066/comments"},"review_comments":{"href":"https://api.github.com/repos/spree/spree/pulls/6066/comments"},"review_comment":{"href":"https://api.github.com/repos/spree/spree/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/spree/spree/pulls/6066/commits"},"statuses":{"href":"https://api.github.com/repos/spree/spree/statuses/5c7be7922d5576298487346e8e2da45d975f076d"}}}}