{"action":"created","comment":{"url":"https://api.github.com/repos/RuFalcon/thinknetica/pulls/comments/28400058","id":28400058,"diff_hunk":"@@ -0,0 +1,6 @@\n+class Vote < ActiveRecord::Base\n+  belongs_to :user\n+  belongs_to :votable, polymorphic: true\n+\n+  scope :rating, -> { pluck(:value).sum }","path":"app/models/vote.rb","position":5,"original_position":5,"commit_id":"cb7312a7cb2038f89dfbb242bf92e1a0180e7800","original_commit_id":"cb7312a7cb2038f89dfbb242bf92e1a0180e7800","user":{"login":"palkan","id":1516722,"avatar_url":"https://avatars.githubusercontent.com/u/1516722?v=3","gravatar_id":"","url":"https://api.github.com/users/palkan","html_url":"https://github.com/palkan","followers_url":"https://api.github.com/users/palkan/followers","following_url":"https://api.github.com/users/palkan/following{/other_user}","gists_url":"https://api.github.com/users/palkan/gists{/gist_id}","starred_url":"https://api.github.com/users/palkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palkan/subscriptions","organizations_url":"https://api.github.com/users/palkan/orgs","repos_url":"https://api.github.com/users/palkan/repos","events_url":"https://api.github.com/users/palkan/events{/privacy}","received_events_url":"https://api.github.com/users/palkan/received_events","type":"User","site_admin":false},"body":"Сейчас это запрос `select value from votes` и дальнейшее суммирование на стороне руби, а можно просто `sum(:value)`.\r\n\r\nИ это все-таки не scope, так как возвращает число. Скоуп должен возвращать `ActiveRecord::Relation`, чтобы его можно было объединить с другими условиями. ","created_at":"2015-04-15T07:56:29Z","updated_at":"2015-04-15T07:56:29Z","html_url":"https://github.com/RuFalcon/thinknetica/pull/7#discussion_r28400058","pull_request_url":"https://api.github.com/repos/RuFalcon/thinknetica/pulls/7","_links":{"self":{"href":"https://api.github.com/repos/RuFalcon/thinknetica/pulls/comments/28400058"},"html":{"href":"https://github.com/RuFalcon/thinknetica/pull/7#discussion_r28400058"},"pull_request":{"href":"https://api.github.com/repos/RuFalcon/thinknetica/pulls/7"}}},"pull_request":{"url":"https://api.github.com/repos/RuFalcon/thinknetica/pulls/7","id":33329476,"html_url":"https://github.com/RuFalcon/thinknetica/pull/7","diff_url":"https://github.com/RuFalcon/thinknetica/pull/7.diff","patch_url":"https://github.com/RuFalcon/thinknetica/pull/7.patch","issue_url":"https://api.github.com/repos/RuFalcon/thinknetica/issues/7","number":7,"state":"open","locked":false,"title":"Json","user":{"login":"RuFalcon","id":4472658,"avatar_url":"https://avatars.githubusercontent.com/u/4472658?v=3","gravatar_id":"","url":"https://api.github.com/users/RuFalcon","html_url":"https://github.com/RuFalcon","followers_url":"https://api.github.com/users/RuFalcon/followers","following_url":"https://api.github.com/users/RuFalcon/following{/other_user}","gists_url":"https://api.github.com/users/RuFalcon/gists{/gist_id}","starred_url":"https://api.github.com/users/RuFalcon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RuFalcon/subscriptions","organizations_url":"https://api.github.com/users/RuFalcon/orgs","repos_url":"https://api.github.com/users/RuFalcon/repos","events_url":"https://api.github.com/users/RuFalcon/events{/privacy}","received_events_url":"https://api.github.com/users/RuFalcon/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-04-15T07:40:23Z","updated_at":"2015-04-15T07:56:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e3291299c7f1189721bc90da66cea08475847686","assignee":{"login":"palkan","id":1516722,"avatar_url":"https://avatars.githubusercontent.com/u/1516722?v=3","gravatar_id":"","url":"https://api.github.com/users/palkan","html_url":"https://github.com/palkan","followers_url":"https://api.github.com/users/palkan/followers","following_url":"https://api.github.com/users/palkan/following{/other_user}","gists_url":"https://api.github.com/users/palkan/gists{/gist_id}","starred_url":"https://api.github.com/users/palkan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/palkan/subscriptions","organizations_url":"https://api.github.com/users/palkan/orgs","repos_url":"https://api.github.com/users/palkan/repos","events_url":"https://api.github.com/users/palkan/events{/privacy}","received_events_url":"https://api.github.com/users/palkan/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/RuFalcon/thinknetica/pulls/7/commits","review_comments_url":"https://api.github.com/repos/RuFalcon/thinknetica/pulls/7/comments","review_comment_url":"https://api.github.com/repos/RuFalcon/thinknetica/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RuFalcon/thinknetica/issues/7/comments","statuses_url":"https://api.github.com/repos/RuFalcon/thinknetica/statuses/cb7312a7cb2038f89dfbb242bf92e1a0180e7800","head":{"label":"RuFalcon:json","ref":"json","sha":"cb7312a7cb2038f89dfbb242bf92e1a0180e7800","user":{"login":"RuFalcon","id":4472658,"avatar_url":"https://avatars.githubusercontent.com/u/4472658?v=3","gravatar_id":"","url":"https://api.github.com/users/RuFalcon","html_url":"https://github.com/RuFalcon","followers_url":"https://api.github.com/users/RuFalcon/followers","following_url":"https://api.github.com/users/RuFalcon/following{/other_user}","gists_url":"https://api.github.com/users/RuFalcon/gists{/gist_id}","starred_url":"https://api.github.com/users/RuFalcon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RuFalcon/subscriptions","organizations_url":"https://api.github.com/users/RuFalcon/orgs","repos_url":"https://api.github.com/users/RuFalcon/repos","events_url":"https://api.github.com/users/RuFalcon/events{/privacy}","received_events_url":"https://api.github.com/users/RuFalcon/received_events","type":"User","site_admin":false},"repo":{"id":31947742,"name":"thinknetica","full_name":"RuFalcon/thinknetica","owner":{"login":"RuFalcon","id":4472658,"avatar_url":"https://avatars.githubusercontent.com/u/4472658?v=3","gravatar_id":"","url":"https://api.github.com/users/RuFalcon","html_url":"https://github.com/RuFalcon","followers_url":"https://api.github.com/users/RuFalcon/followers","following_url":"https://api.github.com/users/RuFalcon/following{/other_user}","gists_url":"https://api.github.com/users/RuFalcon/gists{/gist_id}","starred_url":"https://api.github.com/users/RuFalcon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RuFalcon/subscriptions","organizations_url":"https://api.github.com/users/RuFalcon/orgs","repos_url":"https://api.github.com/users/RuFalcon/repos","events_url":"https://api.github.com/users/RuFalcon/events{/privacy}","received_events_url":"https://api.github.com/users/RuFalcon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RuFalcon/thinknetica","description":"","fork":false,"url":"https://api.github.com/repos/RuFalcon/thinknetica","forks_url":"https://api.github.com/repos/RuFalcon/thinknetica/forks","keys_url":"https://api.github.com/repos/RuFalcon/thinknetica/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RuFalcon/thinknetica/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RuFalcon/thinknetica/teams","hooks_url":"https://api.github.com/repos/RuFalcon/thinknetica/hooks","issue_events_url":"https://api.github.com/repos/RuFalcon/thinknetica/issues/events{/number}","events_url":"https://api.github.com/repos/RuFalcon/thinknetica/events","assignees_url":"https://api.github.com/repos/RuFalcon/thinknetica/assignees{/user}","branches_url":"https://api.github.com/repos/RuFalcon/thinknetica/branches{/branch}","tags_url":"https://api.github.com/repos/RuFalcon/thinknetica/tags","blobs_url":"https://api.github.com/repos/RuFalcon/thinknetica/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RuFalcon/thinknetica/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RuFalcon/thinknetica/git/refs{/sha}","trees_url":"https://api.github.com/repos/RuFalcon/thinknetica/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RuFalcon/thinknetica/statuses/{sha}","languages_url":"https://api.github.com/repos/RuFalcon/thinknetica/languages","stargazers_url":"https://api.github.com/repos/RuFalcon/thinknetica/stargazers","contributors_url":"https://api.github.com/repos/RuFalcon/thinknetica/contributors","subscribers_url":"https://api.github.com/repos/RuFalcon/thinknetica/subscribers","subscription_url":"https://api.github.com/repos/RuFalcon/thinknetica/subscription","commits_url":"https://api.github.com/repos/RuFalcon/thinknetica/commits{/sha}","git_commits_url":"https://api.github.com/repos/RuFalcon/thinknetica/git/commits{/sha}","comments_url":"https://api.github.com/repos/RuFalcon/thinknetica/comments{/number}","issue_comment_url":"https://api.github.com/repos/RuFalcon/thinknetica/issues/comments{/number}","contents_url":"https://api.github.com/repos/RuFalcon/thinknetica/contents/{+path}","compare_url":"https://api.github.com/repos/RuFalcon/thinknetica/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RuFalcon/thinknetica/merges","archive_url":"https://api.github.com/repos/RuFalcon/thinknetica/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RuFalcon/thinknetica/downloads","issues_url":"https://api.github.com/repos/RuFalcon/thinknetica/issues{/number}","pulls_url":"https://api.github.com/repos/RuFalcon/thinknetica/pulls{/number}","milestones_url":"https://api.github.com/repos/RuFalcon/thinknetica/milestones{/number}","notifications_url":"https://api.github.com/repos/RuFalcon/thinknetica/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RuFalcon/thinknetica/labels{/name}","releases_url":"https://api.github.com/repos/RuFalcon/thinknetica/releases{/id}","created_at":"2015-03-10T09:06:44Z","updated_at":"2015-04-08T06:27:52Z","pushed_at":"2015-04-15T07:40:23Z","git_url":"git://github.com/RuFalcon/thinknetica.git","ssh_url":"git@github.com:RuFalcon/thinknetica.git","clone_url":"https://github.com/RuFalcon/thinknetica.git","svn_url":"https://github.com/RuFalcon/thinknetica","homepage":null,"size":555,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"RuFalcon:master","ref":"master","sha":"687d97194d063dd4abe0153bbc3be326ee7a7646","user":{"login":"RuFalcon","id":4472658,"avatar_url":"https://avatars.githubusercontent.com/u/4472658?v=3","gravatar_id":"","url":"https://api.github.com/users/RuFalcon","html_url":"https://github.com/RuFalcon","followers_url":"https://api.github.com/users/RuFalcon/followers","following_url":"https://api.github.com/users/RuFalcon/following{/other_user}","gists_url":"https://api.github.com/users/RuFalcon/gists{/gist_id}","starred_url":"https://api.github.com/users/RuFalcon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RuFalcon/subscriptions","organizations_url":"https://api.github.com/users/RuFalcon/orgs","repos_url":"https://api.github.com/users/RuFalcon/repos","events_url":"https://api.github.com/users/RuFalcon/events{/privacy}","received_events_url":"https://api.github.com/users/RuFalcon/received_events","type":"User","site_admin":false},"repo":{"id":31947742,"name":"thinknetica","full_name":"RuFalcon/thinknetica","owner":{"login":"RuFalcon","id":4472658,"avatar_url":"https://avatars.githubusercontent.com/u/4472658?v=3","gravatar_id":"","url":"https://api.github.com/users/RuFalcon","html_url":"https://github.com/RuFalcon","followers_url":"https://api.github.com/users/RuFalcon/followers","following_url":"https://api.github.com/users/RuFalcon/following{/other_user}","gists_url":"https://api.github.com/users/RuFalcon/gists{/gist_id}","starred_url":"https://api.github.com/users/RuFalcon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RuFalcon/subscriptions","organizations_url":"https://api.github.com/users/RuFalcon/orgs","repos_url":"https://api.github.com/users/RuFalcon/repos","events_url":"https://api.github.com/users/RuFalcon/events{/privacy}","received_events_url":"https://api.github.com/users/RuFalcon/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RuFalcon/thinknetica","description":"","fork":false,"url":"https://api.github.com/repos/RuFalcon/thinknetica","forks_url":"https://api.github.com/repos/RuFalcon/thinknetica/forks","keys_url":"https://api.github.com/repos/RuFalcon/thinknetica/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RuFalcon/thinknetica/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RuFalcon/thinknetica/teams","hooks_url":"https://api.github.com/repos/RuFalcon/thinknetica/hooks","issue_events_url":"https://api.github.com/repos/RuFalcon/thinknetica/issues/events{/number}","events_url":"https://api.github.com/repos/RuFalcon/thinknetica/events","assignees_url":"https://api.github.com/repos/RuFalcon/thinknetica/assignees{/user}","branches_url":"https://api.github.com/repos/RuFalcon/thinknetica/branches{/branch}","tags_url":"https://api.github.com/repos/RuFalcon/thinknetica/tags","blobs_url":"https://api.github.com/repos/RuFalcon/thinknetica/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RuFalcon/thinknetica/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RuFalcon/thinknetica/git/refs{/sha}","trees_url":"https://api.github.com/repos/RuFalcon/thinknetica/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RuFalcon/thinknetica/statuses/{sha}","languages_url":"https://api.github.com/repos/RuFalcon/thinknetica/languages","stargazers_url":"https://api.github.com/repos/RuFalcon/thinknetica/stargazers","contributors_url":"https://api.github.com/repos/RuFalcon/thinknetica/contributors","subscribers_url":"https://api.github.com/repos/RuFalcon/thinknetica/subscribers","subscription_url":"https://api.github.com/repos/RuFalcon/thinknetica/subscription","commits_url":"https://api.github.com/repos/RuFalcon/thinknetica/commits{/sha}","git_commits_url":"https://api.github.com/repos/RuFalcon/thinknetica/git/commits{/sha}","comments_url":"https://api.github.com/repos/RuFalcon/thinknetica/comments{/number}","issue_comment_url":"https://api.github.com/repos/RuFalcon/thinknetica/issues/comments{/number}","contents_url":"https://api.github.com/repos/RuFalcon/thinknetica/contents/{+path}","compare_url":"https://api.github.com/repos/RuFalcon/thinknetica/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RuFalcon/thinknetica/merges","archive_url":"https://api.github.com/repos/RuFalcon/thinknetica/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RuFalcon/thinknetica/downloads","issues_url":"https://api.github.com/repos/RuFalcon/thinknetica/issues{/number}","pulls_url":"https://api.github.com/repos/RuFalcon/thinknetica/pulls{/number}","milestones_url":"https://api.github.com/repos/RuFalcon/thinknetica/milestones{/number}","notifications_url":"https://api.github.com/repos/RuFalcon/thinknetica/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RuFalcon/thinknetica/labels{/name}","releases_url":"https://api.github.com/repos/RuFalcon/thinknetica/releases{/id}","created_at":"2015-03-10T09:06:44Z","updated_at":"2015-04-08T06:27:52Z","pushed_at":"2015-04-15T07:40:23Z","git_url":"git://github.com/RuFalcon/thinknetica.git","ssh_url":"git@github.com:RuFalcon/thinknetica.git","clone_url":"https://github.com/RuFalcon/thinknetica.git","svn_url":"https://github.com/RuFalcon/thinknetica","homepage":null,"size":555,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/RuFalcon/thinknetica/pulls/7"},"html":{"href":"https://github.com/RuFalcon/thinknetica/pull/7"},"issue":{"href":"https://api.github.com/repos/RuFalcon/thinknetica/issues/7"},"comments":{"href":"https://api.github.com/repos/RuFalcon/thinknetica/issues/7/comments"},"review_comments":{"href":"https://api.github.com/repos/RuFalcon/thinknetica/pulls/7/comments"},"review_comment":{"href":"https://api.github.com/repos/RuFalcon/thinknetica/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RuFalcon/thinknetica/pulls/7/commits"},"statuses":{"href":"https://api.github.com/repos/RuFalcon/thinknetica/statuses/cb7312a7cb2038f89dfbb242bf92e1a0180e7800"}}}}