{"action":"opened","number":1154,"pull_request":{"url":"https://api.github.com/repos/rubygems/rubygems.org/pulls/1154","id":54603588,"html_url":"https://github.com/rubygems/rubygems.org/pull/1154","diff_url":"https://github.com/rubygems/rubygems.org/pull/1154.diff","patch_url":"https://github.com/rubygems/rubygems.org/pull/1154.patch","issue_url":"https://api.github.com/repos/rubygems/rubygems.org/issues/1154","number":1154,"state":"open","locked":false,"title":"Add runtime/dev dependencies counts to Version","user":{"login":"olivierlacan","id":65950,"avatar_url":"https://avatars.githubusercontent.com/u/65950?v=3","gravatar_id":"","url":"https://api.github.com/users/olivierlacan","html_url":"https://github.com/olivierlacan","followers_url":"https://api.github.com/users/olivierlacan/followers","following_url":"https://api.github.com/users/olivierlacan/following{/other_user}","gists_url":"https://api.github.com/users/olivierlacan/gists{/gist_id}","starred_url":"https://api.github.com/users/olivierlacan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olivierlacan/subscriptions","organizations_url":"https://api.github.com/users/olivierlacan/orgs","repos_url":"https://api.github.com/users/olivierlacan/repos","events_url":"https://api.github.com/users/olivierlacan/events{/privacy}","received_events_url":"https://api.github.com/users/olivierlacan/received_events","type":"User","site_admin":false},"body":"Addresses #1115\r\n\r\nFor now I'm dynamically calling `count` on the two scopes of the dependencies association on Version.\r\n\r\nThis generates the following extra query:\r\n\r\nSELECT COUNT(DISTINCT \"dependencies\".\"id\") FROM \"dependencies\" LEFT OUTER JOIN \"rubygems\" ON \"rubygems\".\"id\" = \"dependencies\".\"rubygem_id\" WHERE \"dependencies\".\"version_id\" = $1 AND \"dependencies\".\"scope\" = $2  [[\"version_id\", 125], [\"scope\", \"runtime\"]]\r\n\r\nOne is triggered per dependencies scope (runtime, development) and none if the gem's version has neither runtime nor development dependencies.\r\n\r\nI'm not sure the cost of that query is worth the added latency so it would probably be a good idea to calculate these counts when a version is created and just use a counter cache column on the version\r\ntable or in Redis. That's assuming we're okay adding two new columns (or Redis keys): `runtime_dependencies_count` and `development_dependencies_count` to the `versions` table. \r\n\r\nLet me know if the above is palatable and what the preferred way to hook in to the version creation lifecycle is: ActiveRecord callbacks, Redis, or something fancier?\r\n\r\n/cc @dwradcliffe ","created_at":"2015-12-26T15:20:58Z","updated_at":"2015-12-26T15:20:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/rubygems/rubygems.org/pulls/1154/commits","review_comments_url":"https://api.github.com/repos/rubygems/rubygems.org/pulls/1154/comments","review_comment_url":"https://api.github.com/repos/rubygems/rubygems.org/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rubygems/rubygems.org/issues/1154/comments","statuses_url":"https://api.github.com/repos/rubygems/rubygems.org/statuses/b7aca3f398c17a10d913da9da719de15a3205f19","head":{"label":"olivierlacan:dependencies-counts","ref":"dependencies-counts","sha":"b7aca3f398c17a10d913da9da719de15a3205f19","user":{"login":"olivierlacan","id":65950,"avatar_url":"https://avatars.githubusercontent.com/u/65950?v=3","gravatar_id":"","url":"https://api.github.com/users/olivierlacan","html_url":"https://github.com/olivierlacan","followers_url":"https://api.github.com/users/olivierlacan/followers","following_url":"https://api.github.com/users/olivierlacan/following{/other_user}","gists_url":"https://api.github.com/users/olivierlacan/gists{/gist_id}","starred_url":"https://api.github.com/users/olivierlacan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olivierlacan/subscriptions","organizations_url":"https://api.github.com/users/olivierlacan/orgs","repos_url":"https://api.github.com/users/olivierlacan/repos","events_url":"https://api.github.com/users/olivierlacan/events{/privacy}","received_events_url":"https://api.github.com/users/olivierlacan/received_events","type":"User","site_admin":false},"repo":{"id":17946351,"name":"rubygems.org","full_name":"olivierlacan/rubygems.org","owner":{"login":"olivierlacan","id":65950,"avatar_url":"https://avatars.githubusercontent.com/u/65950?v=3","gravatar_id":"","url":"https://api.github.com/users/olivierlacan","html_url":"https://github.com/olivierlacan","followers_url":"https://api.github.com/users/olivierlacan/followers","following_url":"https://api.github.com/users/olivierlacan/following{/other_user}","gists_url":"https://api.github.com/users/olivierlacan/gists{/gist_id}","starred_url":"https://api.github.com/users/olivierlacan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/olivierlacan/subscriptions","organizations_url":"https://api.github.com/users/olivierlacan/orgs","repos_url":"https://api.github.com/users/olivierlacan/repos","events_url":"https://api.github.com/users/olivierlacan/events{/privacy}","received_events_url":"https://api.github.com/users/olivierlacan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/olivierlacan/rubygems.org","description":"The Ruby community's gem hosting service.","fork":true,"url":"https://api.github.com/repos/olivierlacan/rubygems.org","forks_url":"https://api.github.com/repos/olivierlacan/rubygems.org/forks","keys_url":"https://api.github.com/repos/olivierlacan/rubygems.org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/olivierlacan/rubygems.org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/olivierlacan/rubygems.org/teams","hooks_url":"https://api.github.com/repos/olivierlacan/rubygems.org/hooks","issue_events_url":"https://api.github.com/repos/olivierlacan/rubygems.org/issues/events{/number}","events_url":"https://api.github.com/repos/olivierlacan/rubygems.org/events","assignees_url":"https://api.github.com/repos/olivierlacan/rubygems.org/assignees{/user}","branches_url":"https://api.github.com/repos/olivierlacan/rubygems.org/branches{/branch}","tags_url":"https://api.github.com/repos/olivierlacan/rubygems.org/tags","blobs_url":"https://api.github.com/repos/olivierlacan/rubygems.org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/olivierlacan/rubygems.org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/olivierlacan/rubygems.org/git/refs{/sha}","trees_url":"https://api.github.com/repos/olivierlacan/rubygems.org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/olivierlacan/rubygems.org/statuses/{sha}","languages_url":"https://api.github.com/repos/olivierlacan/rubygems.org/languages","stargazers_url":"https://api.github.com/repos/olivierlacan/rubygems.org/stargazers","contributors_url":"https://api.github.com/repos/olivierlacan/rubygems.org/contributors","subscribers_url":"https://api.github.com/repos/olivierlacan/rubygems.org/subscribers","subscription_url":"https://api.github.com/repos/olivierlacan/rubygems.org/subscription","commits_url":"https://api.github.com/repos/olivierlacan/rubygems.org/commits{/sha}","git_commits_url":"https://api.github.com/repos/olivierlacan/rubygems.org/git/commits{/sha}","comments_url":"https://api.github.com/repos/olivierlacan/rubygems.org/comments{/number}","issue_comment_url":"https://api.github.com/repos/olivierlacan/rubygems.org/issues/comments{/number}","contents_url":"https://api.github.com/repos/olivierlacan/rubygems.org/contents/{+path}","compare_url":"https://api.github.com/repos/olivierlacan/rubygems.org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/olivierlacan/rubygems.org/merges","archive_url":"https://api.github.com/repos/olivierlacan/rubygems.org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/olivierlacan/rubygems.org/downloads","issues_url":"https://api.github.com/repos/olivierlacan/rubygems.org/issues{/number}","pulls_url":"https://api.github.com/repos/olivierlacan/rubygems.org/pulls{/number}","milestones_url":"https://api.github.com/repos/olivierlacan/rubygems.org/milestones{/number}","notifications_url":"https://api.github.com/repos/olivierlacan/rubygems.org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/olivierlacan/rubygems.org/labels{/name}","releases_url":"https://api.github.com/repos/olivierlacan/rubygems.org/releases{/id}","created_at":"2014-03-20T14:50:00Z","updated_at":"2015-11-09T02:48:54Z","pushed_at":"2015-12-26T15:12:28Z","git_url":"git://github.com/olivierlacan/rubygems.org.git","ssh_url":"git@github.com:olivierlacan/rubygems.org.git","clone_url":"https://github.com/olivierlacan/rubygems.org.git","svn_url":"https://github.com/olivierlacan/rubygems.org","homepage":"https://rubygems.org","size":423836,"stargazers_count":0,"watchers_count":0,"language":"HTML","has_issues":false,"has_downloads":false,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rubygems:master","ref":"master","sha":"415fc5293cfd8212946726ca73446f4c3e2d95bb","user":{"login":"rubygems","id":208761,"avatar_url":"https://avatars.githubusercontent.com/u/208761?v=3","gravatar_id":"","url":"https://api.github.com/users/rubygems","html_url":"https://github.com/rubygems","followers_url":"https://api.github.com/users/rubygems/followers","following_url":"https://api.github.com/users/rubygems/following{/other_user}","gists_url":"https://api.github.com/users/rubygems/gists{/gist_id}","starred_url":"https://api.github.com/users/rubygems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubygems/subscriptions","organizations_url":"https://api.github.com/users/rubygems/orgs","repos_url":"https://api.github.com/users/rubygems/repos","events_url":"https://api.github.com/users/rubygems/events{/privacy}","received_events_url":"https://api.github.com/users/rubygems/received_events","type":"Organization","site_admin":false},"repo":{"id":117646,"name":"rubygems.org","full_name":"rubygems/rubygems.org","owner":{"login":"rubygems","id":208761,"avatar_url":"https://avatars.githubusercontent.com/u/208761?v=3","gravatar_id":"","url":"https://api.github.com/users/rubygems","html_url":"https://github.com/rubygems","followers_url":"https://api.github.com/users/rubygems/followers","following_url":"https://api.github.com/users/rubygems/following{/other_user}","gists_url":"https://api.github.com/users/rubygems/gists{/gist_id}","starred_url":"https://api.github.com/users/rubygems/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rubygems/subscriptions","organizations_url":"https://api.github.com/users/rubygems/orgs","repos_url":"https://api.github.com/users/rubygems/repos","events_url":"https://api.github.com/users/rubygems/events{/privacy}","received_events_url":"https://api.github.com/users/rubygems/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rubygems/rubygems.org","description":"The Ruby community's gem hosting service.","fork":false,"url":"https://api.github.com/repos/rubygems/rubygems.org","forks_url":"https://api.github.com/repos/rubygems/rubygems.org/forks","keys_url":"https://api.github.com/repos/rubygems/rubygems.org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rubygems/rubygems.org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rubygems/rubygems.org/teams","hooks_url":"https://api.github.com/repos/rubygems/rubygems.org/hooks","issue_events_url":"https://api.github.com/repos/rubygems/rubygems.org/issues/events{/number}","events_url":"https://api.github.com/repos/rubygems/rubygems.org/events","assignees_url":"https://api.github.com/repos/rubygems/rubygems.org/assignees{/user}","branches_url":"https://api.github.com/repos/rubygems/rubygems.org/branches{/branch}","tags_url":"https://api.github.com/repos/rubygems/rubygems.org/tags","blobs_url":"https://api.github.com/repos/rubygems/rubygems.org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rubygems/rubygems.org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rubygems/rubygems.org/git/refs{/sha}","trees_url":"https://api.github.com/repos/rubygems/rubygems.org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rubygems/rubygems.org/statuses/{sha}","languages_url":"https://api.github.com/repos/rubygems/rubygems.org/languages","stargazers_url":"https://api.github.com/repos/rubygems/rubygems.org/stargazers","contributors_url":"https://api.github.com/repos/rubygems/rubygems.org/contributors","subscribers_url":"https://api.github.com/repos/rubygems/rubygems.org/subscribers","subscription_url":"https://api.github.com/repos/rubygems/rubygems.org/subscription","commits_url":"https://api.github.com/repos/rubygems/rubygems.org/commits{/sha}","git_commits_url":"https://api.github.com/repos/rubygems/rubygems.org/git/commits{/sha}","comments_url":"https://api.github.com/repos/rubygems/rubygems.org/comments{/number}","issue_comment_url":"https://api.github.com/repos/rubygems/rubygems.org/issues/comments{/number}","contents_url":"https://api.github.com/repos/rubygems/rubygems.org/contents/{+path}","compare_url":"https://api.github.com/repos/rubygems/rubygems.org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rubygems/rubygems.org/merges","archive_url":"https://api.github.com/repos/rubygems/rubygems.org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rubygems/rubygems.org/downloads","issues_url":"https://api.github.com/repos/rubygems/rubygems.org/issues{/number}","pulls_url":"https://api.github.com/repos/rubygems/rubygems.org/pulls{/number}","milestones_url":"https://api.github.com/repos/rubygems/rubygems.org/milestones{/number}","notifications_url":"https://api.github.com/repos/rubygems/rubygems.org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rubygems/rubygems.org/labels{/name}","releases_url":"https://api.github.com/repos/rubygems/rubygems.org/releases{/id}","created_at":"2009-01-29T22:30:46Z","updated_at":"2015-12-26T06:48:31Z","pushed_at":"2015-12-26T03:58:45Z","git_url":"git://github.com/rubygems/rubygems.org.git","ssh_url":"git@github.com:rubygems/rubygems.org.git","clone_url":"https://github.com/rubygems/rubygems.org.git","svn_url":"https://github.com/rubygems/rubygems.org","homepage":"https://rubygems.org","size":634998,"stargazers_count":1290,"watchers_count":1290,"language":"HTML","has_issues":true,"has_downloads":false,"has_wiki":true,"has_pages":false,"forks_count":517,"mirror_url":null,"open_issues_count":45,"forks":517,"open_issues":45,"watchers":1290,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rubygems/rubygems.org/pulls/1154"},"html":{"href":"https://github.com/rubygems/rubygems.org/pull/1154"},"issue":{"href":"https://api.github.com/repos/rubygems/rubygems.org/issues/1154"},"comments":{"href":"https://api.github.com/repos/rubygems/rubygems.org/issues/1154/comments"},"review_comments":{"href":"https://api.github.com/repos/rubygems/rubygems.org/pulls/1154/comments"},"review_comment":{"href":"https://api.github.com/repos/rubygems/rubygems.org/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rubygems/rubygems.org/pulls/1154/commits"},"statuses":{"href":"https://api.github.com/repos/rubygems/rubygems.org/statuses/b7aca3f398c17a10d913da9da719de15a3205f19"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":29,"deletions":21,"changed_files":5}}