{"action":"created","comment":{"url":"https://api.github.com/repos/RoadBytes/myflix/pulls/comments/33155408","id":33155408,"diff_hunk":"@@ -1,12 +1,27 @@\n class Video < ActiveRecord::Base\n-  belongs_to :category\n-\n   validates :title, presence: true\n   validates :description, presence: true\n \n+  belongs_to :category\n+  has_many   :reviews, -> { order \"created_at DESC\" }\n \n   def self.search_by_title(title)\n     return [] if title.blank?\n     Video.where('title ILIKE ?', '%' + title + '%')\n   end\n+\n+  def average_rating\n+    return 0 if(review_count < 1)","path":"app/models/video.rb","position":16,"original_position":16,"commit_id":"c31813d84292ac03c5d2028dc0aff32d0bf8448f","original_commit_id":"c31813d84292ac03c5d2028dc0aff32d0bf8448f","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":"`review_count < 1` this could use `Array#empty?` method. `return 0 if reviews.empty?`","created_at":"2015-06-24T14:53:17Z","updated_at":"2015-06-24T14:53:17Z","html_url":"https://github.com/RoadBytes/myflix/pull/4#discussion_r33155408","pull_request_url":"https://api.github.com/repos/RoadBytes/myflix/pulls/4","_links":{"self":{"href":"https://api.github.com/repos/RoadBytes/myflix/pulls/comments/33155408"},"html":{"href":"https://github.com/RoadBytes/myflix/pull/4#discussion_r33155408"},"pull_request":{"href":"https://api.github.com/repos/RoadBytes/myflix/pulls/4"}}},"pull_request":{"url":"https://api.github.com/repos/RoadBytes/myflix/pulls/4","id":38413064,"html_url":"https://github.com/RoadBytes/myflix/pull/4","diff_url":"https://github.com/RoadBytes/myflix/pull/4.diff","patch_url":"https://github.com/RoadBytes/myflix/pull/4.patch","issue_url":"https://api.github.com/repos/RoadBytes/myflix/issues/4","number":4,"state":"open","locked":false,"title":"Adding review features","user":{"login":"RoadBytes","id":6753275,"avatar_url":"https://avatars.githubusercontent.com/u/6753275?v=3","gravatar_id":"","url":"https://api.github.com/users/RoadBytes","html_url":"https://github.com/RoadBytes","followers_url":"https://api.github.com/users/RoadBytes/followers","following_url":"https://api.github.com/users/RoadBytes/following{/other_user}","gists_url":"https://api.github.com/users/RoadBytes/gists{/gist_id}","starred_url":"https://api.github.com/users/RoadBytes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RoadBytes/subscriptions","organizations_url":"https://api.github.com/users/RoadBytes/orgs","repos_url":"https://api.github.com/users/RoadBytes/repos","events_url":"https://api.github.com/users/RoadBytes/events{/privacy}","received_events_url":"https://api.github.com/users/RoadBytes/received_events","type":"User","site_admin":false},"body":"I'll work on committing more, but this is my code for now.  Cheers!","created_at":"2015-06-24T07:02:56Z","updated_at":"2015-06-24T14:53:17Z","closed_at":null,"merged_at":null,"merge_commit_sha":"f8819d89906b7d1ea2069676fd7eae858cc1f4b7","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/RoadBytes/myflix/pulls/4/commits","review_comments_url":"https://api.github.com/repos/RoadBytes/myflix/pulls/4/comments","review_comment_url":"https://api.github.com/repos/RoadBytes/myflix/pulls/comments{/number}","comments_url":"https://api.github.com/repos/RoadBytes/myflix/issues/4/comments","statuses_url":"https://api.github.com/repos/RoadBytes/myflix/statuses/c31813d84292ac03c5d2028dc0aff32d0bf8448f","head":{"label":"RoadBytes:adding_review_features","ref":"adding_review_features","sha":"c31813d84292ac03c5d2028dc0aff32d0bf8448f","user":{"login":"RoadBytes","id":6753275,"avatar_url":"https://avatars.githubusercontent.com/u/6753275?v=3","gravatar_id":"","url":"https://api.github.com/users/RoadBytes","html_url":"https://github.com/RoadBytes","followers_url":"https://api.github.com/users/RoadBytes/followers","following_url":"https://api.github.com/users/RoadBytes/following{/other_user}","gists_url":"https://api.github.com/users/RoadBytes/gists{/gist_id}","starred_url":"https://api.github.com/users/RoadBytes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RoadBytes/subscriptions","organizations_url":"https://api.github.com/users/RoadBytes/orgs","repos_url":"https://api.github.com/users/RoadBytes/repos","events_url":"https://api.github.com/users/RoadBytes/events{/privacy}","received_events_url":"https://api.github.com/users/RoadBytes/received_events","type":"User","site_admin":false},"repo":{"id":36588755,"name":"myflix","full_name":"RoadBytes/myflix","owner":{"login":"RoadBytes","id":6753275,"avatar_url":"https://avatars.githubusercontent.com/u/6753275?v=3","gravatar_id":"","url":"https://api.github.com/users/RoadBytes","html_url":"https://github.com/RoadBytes","followers_url":"https://api.github.com/users/RoadBytes/followers","following_url":"https://api.github.com/users/RoadBytes/following{/other_user}","gists_url":"https://api.github.com/users/RoadBytes/gists{/gist_id}","starred_url":"https://api.github.com/users/RoadBytes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RoadBytes/subscriptions","organizations_url":"https://api.github.com/users/RoadBytes/orgs","repos_url":"https://api.github.com/users/RoadBytes/repos","events_url":"https://api.github.com/users/RoadBytes/events{/privacy}","received_events_url":"https://api.github.com/users/RoadBytes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RoadBytes/myflix","description":"","fork":false,"url":"https://api.github.com/repos/RoadBytes/myflix","forks_url":"https://api.github.com/repos/RoadBytes/myflix/forks","keys_url":"https://api.github.com/repos/RoadBytes/myflix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RoadBytes/myflix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RoadBytes/myflix/teams","hooks_url":"https://api.github.com/repos/RoadBytes/myflix/hooks","issue_events_url":"https://api.github.com/repos/RoadBytes/myflix/issues/events{/number}","events_url":"https://api.github.com/repos/RoadBytes/myflix/events","assignees_url":"https://api.github.com/repos/RoadBytes/myflix/assignees{/user}","branches_url":"https://api.github.com/repos/RoadBytes/myflix/branches{/branch}","tags_url":"https://api.github.com/repos/RoadBytes/myflix/tags","blobs_url":"https://api.github.com/repos/RoadBytes/myflix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RoadBytes/myflix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RoadBytes/myflix/git/refs{/sha}","trees_url":"https://api.github.com/repos/RoadBytes/myflix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RoadBytes/myflix/statuses/{sha}","languages_url":"https://api.github.com/repos/RoadBytes/myflix/languages","stargazers_url":"https://api.github.com/repos/RoadBytes/myflix/stargazers","contributors_url":"https://api.github.com/repos/RoadBytes/myflix/contributors","subscribers_url":"https://api.github.com/repos/RoadBytes/myflix/subscribers","subscription_url":"https://api.github.com/repos/RoadBytes/myflix/subscription","commits_url":"https://api.github.com/repos/RoadBytes/myflix/commits{/sha}","git_commits_url":"https://api.github.com/repos/RoadBytes/myflix/git/commits{/sha}","comments_url":"https://api.github.com/repos/RoadBytes/myflix/comments{/number}","issue_comment_url":"https://api.github.com/repos/RoadBytes/myflix/issues/comments{/number}","contents_url":"https://api.github.com/repos/RoadBytes/myflix/contents/{+path}","compare_url":"https://api.github.com/repos/RoadBytes/myflix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RoadBytes/myflix/merges","archive_url":"https://api.github.com/repos/RoadBytes/myflix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RoadBytes/myflix/downloads","issues_url":"https://api.github.com/repos/RoadBytes/myflix/issues{/number}","pulls_url":"https://api.github.com/repos/RoadBytes/myflix/pulls{/number}","milestones_url":"https://api.github.com/repos/RoadBytes/myflix/milestones{/number}","notifications_url":"https://api.github.com/repos/RoadBytes/myflix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RoadBytes/myflix/labels{/name}","releases_url":"https://api.github.com/repos/RoadBytes/myflix/releases{/id}","created_at":"2015-05-31T05:04:08Z","updated_at":"2015-06-11T10:54:47Z","pushed_at":"2015-06-24T07:02:56Z","git_url":"git://github.com/RoadBytes/myflix.git","ssh_url":"git@github.com:RoadBytes/myflix.git","clone_url":"https://github.com/RoadBytes/myflix.git","svn_url":"https://github.com/RoadBytes/myflix","homepage":null,"size":392,"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":"RoadBytes:master","ref":"master","sha":"c778722e3e3f4f2efdea323bf591de9a5e8478ec","user":{"login":"RoadBytes","id":6753275,"avatar_url":"https://avatars.githubusercontent.com/u/6753275?v=3","gravatar_id":"","url":"https://api.github.com/users/RoadBytes","html_url":"https://github.com/RoadBytes","followers_url":"https://api.github.com/users/RoadBytes/followers","following_url":"https://api.github.com/users/RoadBytes/following{/other_user}","gists_url":"https://api.github.com/users/RoadBytes/gists{/gist_id}","starred_url":"https://api.github.com/users/RoadBytes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RoadBytes/subscriptions","organizations_url":"https://api.github.com/users/RoadBytes/orgs","repos_url":"https://api.github.com/users/RoadBytes/repos","events_url":"https://api.github.com/users/RoadBytes/events{/privacy}","received_events_url":"https://api.github.com/users/RoadBytes/received_events","type":"User","site_admin":false},"repo":{"id":36588755,"name":"myflix","full_name":"RoadBytes/myflix","owner":{"login":"RoadBytes","id":6753275,"avatar_url":"https://avatars.githubusercontent.com/u/6753275?v=3","gravatar_id":"","url":"https://api.github.com/users/RoadBytes","html_url":"https://github.com/RoadBytes","followers_url":"https://api.github.com/users/RoadBytes/followers","following_url":"https://api.github.com/users/RoadBytes/following{/other_user}","gists_url":"https://api.github.com/users/RoadBytes/gists{/gist_id}","starred_url":"https://api.github.com/users/RoadBytes/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RoadBytes/subscriptions","organizations_url":"https://api.github.com/users/RoadBytes/orgs","repos_url":"https://api.github.com/users/RoadBytes/repos","events_url":"https://api.github.com/users/RoadBytes/events{/privacy}","received_events_url":"https://api.github.com/users/RoadBytes/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/RoadBytes/myflix","description":"","fork":false,"url":"https://api.github.com/repos/RoadBytes/myflix","forks_url":"https://api.github.com/repos/RoadBytes/myflix/forks","keys_url":"https://api.github.com/repos/RoadBytes/myflix/keys{/key_id}","collaborators_url":"https://api.github.com/repos/RoadBytes/myflix/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/RoadBytes/myflix/teams","hooks_url":"https://api.github.com/repos/RoadBytes/myflix/hooks","issue_events_url":"https://api.github.com/repos/RoadBytes/myflix/issues/events{/number}","events_url":"https://api.github.com/repos/RoadBytes/myflix/events","assignees_url":"https://api.github.com/repos/RoadBytes/myflix/assignees{/user}","branches_url":"https://api.github.com/repos/RoadBytes/myflix/branches{/branch}","tags_url":"https://api.github.com/repos/RoadBytes/myflix/tags","blobs_url":"https://api.github.com/repos/RoadBytes/myflix/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/RoadBytes/myflix/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/RoadBytes/myflix/git/refs{/sha}","trees_url":"https://api.github.com/repos/RoadBytes/myflix/git/trees{/sha}","statuses_url":"https://api.github.com/repos/RoadBytes/myflix/statuses/{sha}","languages_url":"https://api.github.com/repos/RoadBytes/myflix/languages","stargazers_url":"https://api.github.com/repos/RoadBytes/myflix/stargazers","contributors_url":"https://api.github.com/repos/RoadBytes/myflix/contributors","subscribers_url":"https://api.github.com/repos/RoadBytes/myflix/subscribers","subscription_url":"https://api.github.com/repos/RoadBytes/myflix/subscription","commits_url":"https://api.github.com/repos/RoadBytes/myflix/commits{/sha}","git_commits_url":"https://api.github.com/repos/RoadBytes/myflix/git/commits{/sha}","comments_url":"https://api.github.com/repos/RoadBytes/myflix/comments{/number}","issue_comment_url":"https://api.github.com/repos/RoadBytes/myflix/issues/comments{/number}","contents_url":"https://api.github.com/repos/RoadBytes/myflix/contents/{+path}","compare_url":"https://api.github.com/repos/RoadBytes/myflix/compare/{base}...{head}","merges_url":"https://api.github.com/repos/RoadBytes/myflix/merges","archive_url":"https://api.github.com/repos/RoadBytes/myflix/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/RoadBytes/myflix/downloads","issues_url":"https://api.github.com/repos/RoadBytes/myflix/issues{/number}","pulls_url":"https://api.github.com/repos/RoadBytes/myflix/pulls{/number}","milestones_url":"https://api.github.com/repos/RoadBytes/myflix/milestones{/number}","notifications_url":"https://api.github.com/repos/RoadBytes/myflix/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/RoadBytes/myflix/labels{/name}","releases_url":"https://api.github.com/repos/RoadBytes/myflix/releases{/id}","created_at":"2015-05-31T05:04:08Z","updated_at":"2015-06-11T10:54:47Z","pushed_at":"2015-06-24T07:02:56Z","git_url":"git://github.com/RoadBytes/myflix.git","ssh_url":"git@github.com:RoadBytes/myflix.git","clone_url":"https://github.com/RoadBytes/myflix.git","svn_url":"https://github.com/RoadBytes/myflix","homepage":null,"size":392,"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/RoadBytes/myflix/pulls/4"},"html":{"href":"https://github.com/RoadBytes/myflix/pull/4"},"issue":{"href":"https://api.github.com/repos/RoadBytes/myflix/issues/4"},"comments":{"href":"https://api.github.com/repos/RoadBytes/myflix/issues/4/comments"},"review_comments":{"href":"https://api.github.com/repos/RoadBytes/myflix/pulls/4/comments"},"review_comment":{"href":"https://api.github.com/repos/RoadBytes/myflix/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/RoadBytes/myflix/pulls/4/commits"},"statuses":{"href":"https://api.github.com/repos/RoadBytes/myflix/statuses/c31813d84292ac03c5d2028dc0aff32d0bf8448f"}}}}