{"action":"created","comment":{"url":"https://api.github.com/repos/vincedevendra/myflix/pulls/comments/39536761","id":39536761,"diff_hunk":"@@ -14,7 +17,9 @@ def self.search_by_title(search_terms)\n   end\n \n   def average_rating\n-    (reviews.select('rating').map{ |r| r.rating.to_f }.inject('+') / reviews.count).round(1)\n+    if reviews.any?\n+      (reviews.select('rating').map{ |r| r.rating.to_f }.inject('+') / reviews.count).round(1)","path":"app/models/video.rb","position":14,"original_position":14,"commit_id":"06025e5551defa37cc4c1fd7a0b964d1113359ed","original_commit_id":"06025e5551defa37cc4c1fd7a0b964d1113359ed","user":{"login":"tomtomecek","id":7385469,"avatar_url":"https://avatars.githubusercontent.com/u/7385469?v=3","gravatar_id":"","url":"https://api.github.com/users/tomtomecek","html_url":"https://github.com/tomtomecek","followers_url":"https://api.github.com/users/tomtomecek/followers","following_url":"https://api.github.com/users/tomtomecek/following{/other_user}","gists_url":"https://api.github.com/users/tomtomecek/gists{/gist_id}","starred_url":"https://api.github.com/users/tomtomecek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tomtomecek/subscriptions","organizations_url":"https://api.github.com/users/tomtomecek/orgs","repos_url":"https://api.github.com/users/tomtomecek/repos","events_url":"https://api.github.com/users/tomtomecek/events{/privacy}","received_events_url":"https://api.github.com/users/tomtomecek/received_events","type":"User","site_admin":false},"body":"Rather than this - you could benefit from ActiveRecords#average method :) check it out http://api.rubyonrails.org/classes/ActiveRecord/Calculations.html#method-i-average","created_at":"2015-09-15T17:08:22Z","updated_at":"2015-09-15T17:08:22Z","html_url":"https://github.com/vincedevendra/myflix/pull/19#discussion_r39536761","pull_request_url":"https://api.github.com/repos/vincedevendra/myflix/pulls/19","_links":{"self":{"href":"https://api.github.com/repos/vincedevendra/myflix/pulls/comments/39536761"},"html":{"href":"https://github.com/vincedevendra/myflix/pull/19#discussion_r39536761"},"pull_request":{"href":"https://api.github.com/repos/vincedevendra/myflix/pulls/19"}}},"pull_request":{"url":"https://api.github.com/repos/vincedevendra/myflix/pulls/19","id":45058572,"html_url":"https://github.com/vincedevendra/myflix/pull/19","diff_url":"https://github.com/vincedevendra/myflix/pull/19.diff","patch_url":"https://github.com/vincedevendra/myflix/pull/19.patch","issue_url":"https://api.github.com/repos/vincedevendra/myflix/issues/19","number":19,"state":"open","locked":false,"title":"Week 8-3 Advanced Search","user":{"login":"vincedevendra","id":12373198,"avatar_url":"https://avatars.githubusercontent.com/u/12373198?v=3","gravatar_id":"","url":"https://api.github.com/users/vincedevendra","html_url":"https://github.com/vincedevendra","followers_url":"https://api.github.com/users/vincedevendra/followers","following_url":"https://api.github.com/users/vincedevendra/following{/other_user}","gists_url":"https://api.github.com/users/vincedevendra/gists{/gist_id}","starred_url":"https://api.github.com/users/vincedevendra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vincedevendra/subscriptions","organizations_url":"https://api.github.com/users/vincedevendra/orgs","repos_url":"https://api.github.com/users/vincedevendra/repos","events_url":"https://api.github.com/users/vincedevendra/events{/privacy}","received_events_url":"https://api.github.com/users/vincedevendra/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-09-15T14:47:16Z","updated_at":"2015-09-15T17:08:22Z","closed_at":null,"merged_at":null,"merge_commit_sha":"c91cf8297edaddfb824b8f67ecf8a74b884745d1","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/vincedevendra/myflix/pulls/19/commits","review_comments_url":"https://api.github.com/repos/vincedevendra/myflix/pulls/19/comments","review_comment_url":"https://api.github.com/repos/vincedevendra/myflix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/vincedevendra/myflix/issues/19/comments","statuses_url":"https://api.github.com/repos/vincedevendra/myflix/statuses/06025e5551defa37cc4c1fd7a0b964d1113359ed","head":{"label":"vincedevendra:week_8_3","ref":"week_8_3","sha":"06025e5551defa37cc4c1fd7a0b964d1113359ed","user":{"login":"vincedevendra","id":12373198,"avatar_url":"https://avatars.githubusercontent.com/u/12373198?v=3","gravatar_id":"","url":"https://api.github.com/users/vincedevendra","html_url":"https://github.com/vincedevendra","followers_url":"https://api.github.com/users/vincedevendra/followers","following_url":"https://api.github.com/users/vincedevendra/following{/other_user}","gists_url":"https://api.github.com/users/vincedevendra/gists{/gist_id}","starred_url":"https://api.github.com/users/vincedevendra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vincedevendra/subscriptions","organizations_url":"https://api.github.com/users/vincedevendra/orgs","repos_url":"https://api.github.com/users/vincedevendra/repos","events_url":"https://api.github.com/users/vincedevendra/events{/privacy}","received_events_url":"https://api.github.com/users/vincedevendra/received_events","type":"User","site_admin":false},"repo":{"id":39867365,"name":"myflix","full_name":"vincedevendra/myflix","owner":{"login":"vincedevendra","id":12373198,"avatar_url":"https://avatars.githubusercontent.com/u/12373198?v=3","gravatar_id":"","url":"https://api.github.com/users/vincedevendra","html_url":"https://github.com/vincedevendra","followers_url":"https://api.github.com/users/vincedevendra/followers","following_url":"https://api.github.com/users/vincedevendra/following{/other_user}","gists_url":"https://api.github.com/users/vincedevendra/gists{/gist_id}","starred_url":"https://api.github.com/users/vincedevendra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vincedevendra/subscriptions","organizations_url":"https://api.github.com/users/vincedevendra/orgs","repos_url":"https://api.github.com/users/vincedevendra/repos","events_url":"https://api.github.com/users/vincedevendra/events{/privacy}","received_events_url":"https://api.github.com/users/vincedevendra/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vincedevendra/myflix","description":"","fork":false,"url":"https://api.github.com/repos/vincedevendra/myflix","forks_url":"https://api.github.com/repos/vincedevendra/myflix/forks","keys_url":"https://api.github.com/repos/vincedevendra/myflix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vincedevendra/myflix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vincedevendra/myflix/teams","hooks_url":"https://api.github.com/repos/vincedevendra/myflix/hooks","issue_events_url":"https://api.github.com/repos/vincedevendra/myflix/issues/events{/number}","events_url":"https://api.github.com/repos/vincedevendra/myflix/events","assignees_url":"https://api.github.com/repos/vincedevendra/myflix/assignees{/user}","branches_url":"https://api.github.com/repos/vincedevendra/myflix/branches{/branch}","tags_url":"https://api.github.com/repos/vincedevendra/myflix/tags","blobs_url":"https://api.github.com/repos/vincedevendra/myflix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vincedevendra/myflix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vincedevendra/myflix/git/refs{/sha}","trees_url":"https://api.github.com/repos/vincedevendra/myflix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vincedevendra/myflix/statuses/{sha}","languages_url":"https://api.github.com/repos/vincedevendra/myflix/languages","stargazers_url":"https://api.github.com/repos/vincedevendra/myflix/stargazers","contributors_url":"https://api.github.com/repos/vincedevendra/myflix/contributors","subscribers_url":"https://api.github.com/repos/vincedevendra/myflix/subscribers","subscription_url":"https://api.github.com/repos/vincedevendra/myflix/subscription","commits_url":"https://api.github.com/repos/vincedevendra/myflix/commits{/sha}","git_commits_url":"https://api.github.com/repos/vincedevendra/myflix/git/commits{/sha}","comments_url":"https://api.github.com/repos/vincedevendra/myflix/comments{/number}","issue_comment_url":"https://api.github.com/repos/vincedevendra/myflix/issues/comments{/number}","contents_url":"https://api.github.com/repos/vincedevendra/myflix/contents/{+path}","compare_url":"https://api.github.com/repos/vincedevendra/myflix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vincedevendra/myflix/merges","archive_url":"https://api.github.com/repos/vincedevendra/myflix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vincedevendra/myflix/downloads","issues_url":"https://api.github.com/repos/vincedevendra/myflix/issues{/number}","pulls_url":"https://api.github.com/repos/vincedevendra/myflix/pulls{/number}","milestones_url":"https://api.github.com/repos/vincedevendra/myflix/milestones{/number}","notifications_url":"https://api.github.com/repos/vincedevendra/myflix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vincedevendra/myflix/labels{/name}","releases_url":"https://api.github.com/repos/vincedevendra/myflix/releases{/id}","created_at":"2015-07-29T01:53:33Z","updated_at":"2015-08-03T21:23:23Z","pushed_at":"2015-09-15T14:47:16Z","git_url":"git://github.com/vincedevendra/myflix.git","ssh_url":"git@github.com:vincedevendra/myflix.git","clone_url":"https://github.com/vincedevendra/myflix.git","svn_url":"https://github.com/vincedevendra/myflix","homepage":null,"size":720,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"vincedevendra:master","ref":"master","sha":"d0e5e725fdaa78202c37fc41059ea763a7e01a20","user":{"login":"vincedevendra","id":12373198,"avatar_url":"https://avatars.githubusercontent.com/u/12373198?v=3","gravatar_id":"","url":"https://api.github.com/users/vincedevendra","html_url":"https://github.com/vincedevendra","followers_url":"https://api.github.com/users/vincedevendra/followers","following_url":"https://api.github.com/users/vincedevendra/following{/other_user}","gists_url":"https://api.github.com/users/vincedevendra/gists{/gist_id}","starred_url":"https://api.github.com/users/vincedevendra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vincedevendra/subscriptions","organizations_url":"https://api.github.com/users/vincedevendra/orgs","repos_url":"https://api.github.com/users/vincedevendra/repos","events_url":"https://api.github.com/users/vincedevendra/events{/privacy}","received_events_url":"https://api.github.com/users/vincedevendra/received_events","type":"User","site_admin":false},"repo":{"id":39867365,"name":"myflix","full_name":"vincedevendra/myflix","owner":{"login":"vincedevendra","id":12373198,"avatar_url":"https://avatars.githubusercontent.com/u/12373198?v=3","gravatar_id":"","url":"https://api.github.com/users/vincedevendra","html_url":"https://github.com/vincedevendra","followers_url":"https://api.github.com/users/vincedevendra/followers","following_url":"https://api.github.com/users/vincedevendra/following{/other_user}","gists_url":"https://api.github.com/users/vincedevendra/gists{/gist_id}","starred_url":"https://api.github.com/users/vincedevendra/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vincedevendra/subscriptions","organizations_url":"https://api.github.com/users/vincedevendra/orgs","repos_url":"https://api.github.com/users/vincedevendra/repos","events_url":"https://api.github.com/users/vincedevendra/events{/privacy}","received_events_url":"https://api.github.com/users/vincedevendra/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/vincedevendra/myflix","description":"","fork":false,"url":"https://api.github.com/repos/vincedevendra/myflix","forks_url":"https://api.github.com/repos/vincedevendra/myflix/forks","keys_url":"https://api.github.com/repos/vincedevendra/myflix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/vincedevendra/myflix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/vincedevendra/myflix/teams","hooks_url":"https://api.github.com/repos/vincedevendra/myflix/hooks","issue_events_url":"https://api.github.com/repos/vincedevendra/myflix/issues/events{/number}","events_url":"https://api.github.com/repos/vincedevendra/myflix/events","assignees_url":"https://api.github.com/repos/vincedevendra/myflix/assignees{/user}","branches_url":"https://api.github.com/repos/vincedevendra/myflix/branches{/branch}","tags_url":"https://api.github.com/repos/vincedevendra/myflix/tags","blobs_url":"https://api.github.com/repos/vincedevendra/myflix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/vincedevendra/myflix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/vincedevendra/myflix/git/refs{/sha}","trees_url":"https://api.github.com/repos/vincedevendra/myflix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/vincedevendra/myflix/statuses/{sha}","languages_url":"https://api.github.com/repos/vincedevendra/myflix/languages","stargazers_url":"https://api.github.com/repos/vincedevendra/myflix/stargazers","contributors_url":"https://api.github.com/repos/vincedevendra/myflix/contributors","subscribers_url":"https://api.github.com/repos/vincedevendra/myflix/subscribers","subscription_url":"https://api.github.com/repos/vincedevendra/myflix/subscription","commits_url":"https://api.github.com/repos/vincedevendra/myflix/commits{/sha}","git_commits_url":"https://api.github.com/repos/vincedevendra/myflix/git/commits{/sha}","comments_url":"https://api.github.com/repos/vincedevendra/myflix/comments{/number}","issue_comment_url":"https://api.github.com/repos/vincedevendra/myflix/issues/comments{/number}","contents_url":"https://api.github.com/repos/vincedevendra/myflix/contents/{+path}","compare_url":"https://api.github.com/repos/vincedevendra/myflix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/vincedevendra/myflix/merges","archive_url":"https://api.github.com/repos/vincedevendra/myflix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/vincedevendra/myflix/downloads","issues_url":"https://api.github.com/repos/vincedevendra/myflix/issues{/number}","pulls_url":"https://api.github.com/repos/vincedevendra/myflix/pulls{/number}","milestones_url":"https://api.github.com/repos/vincedevendra/myflix/milestones{/number}","notifications_url":"https://api.github.com/repos/vincedevendra/myflix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/vincedevendra/myflix/labels{/name}","releases_url":"https://api.github.com/repos/vincedevendra/myflix/releases{/id}","created_at":"2015-07-29T01:53:33Z","updated_at":"2015-08-03T21:23:23Z","pushed_at":"2015-09-15T14:47:16Z","git_url":"git://github.com/vincedevendra/myflix.git","ssh_url":"git@github.com:vincedevendra/myflix.git","clone_url":"https://github.com/vincedevendra/myflix.git","svn_url":"https://github.com/vincedevendra/myflix","homepage":null,"size":720,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/vincedevendra/myflix/pulls/19"},"html":{"href":"https://github.com/vincedevendra/myflix/pull/19"},"issue":{"href":"https://api.github.com/repos/vincedevendra/myflix/issues/19"},"comments":{"href":"https://api.github.com/repos/vincedevendra/myflix/issues/19/comments"},"review_comments":{"href":"https://api.github.com/repos/vincedevendra/myflix/pulls/19/comments"},"review_comment":{"href":"https://api.github.com/repos/vincedevendra/myflix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/vincedevendra/myflix/pulls/19/commits"},"statuses":{"href":"https://api.github.com/repos/vincedevendra/myflix/statuses/06025e5551defa37cc4c1fd7a0b964d1113359ed"}}}}