{"action":"created","comment":{"url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/pulls/comments/24956828","id":24956828,"diff_hunk":"@@ -0,0 +1,34 @@\n+\n+helpers do\n+\n+  def full_portfolio\n+    current_portfolio.transactions.sort_by { |p| p.buy_datetime }.reverse\n+  end\n+\n+  def current_portfolio\n+    Portfolio.find_by(id: session[:current_portfolio_id])\n+  end\n+\n+  def update_quotes\n+    current_portfolio.transactions.each do |transaction|\n+      begin\n+        quote = Bovespa::Cotacao.new(transaction.stock.ticker)\n+        transaction.stock.quotes.create(price: quote.latest_value, datetime: quote.datetime)\n+      rescue\n+        next\n+      end\n+    end\n+  end\n+\n+  def all_stocks\n+    Stock.all.sort_by { |stock| stock.ticker }\n+  end\n+\n+  def stocks_in_portfolio","path":"app/helpers/portfolio_helper.rb","position":27,"original_position":27,"commit_id":"d4365b6373266ee3ae0eb2b6c8168caa31a232fd","original_commit_id":"d4365b6373266ee3ae0eb2b6c8168caa31a232fd","user":{"login":"jareddbc","id":4805277,"avatar_url":"https://avatars.githubusercontent.com/u/4805277?v=3","gravatar_id":"","url":"https://api.github.com/users/jareddbc","html_url":"https://github.com/jareddbc","followers_url":"https://api.github.com/users/jareddbc/followers","following_url":"https://api.github.com/users/jareddbc/following{/other_user}","gists_url":"https://api.github.com/users/jareddbc/gists{/gist_id}","starred_url":"https://api.github.com/users/jareddbc/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jareddbc/subscriptions","organizations_url":"https://api.github.com/users/jareddbc/orgs","repos_url":"https://api.github.com/users/jareddbc/repos","events_url":"https://api.github.com/users/jareddbc/events{/privacy}","received_events_url":"https://api.github.com/users/jareddbc/received_events","type":"User","site_admin":false},"body":"this will prevent the N+1 query your version has. \r\n```ruby\r\ndef stocks_in_portfolio\r\n  current_portfolio.transactions.includes(:stock).map(&:stock)\r\nend\r\n```","created_at":"2015-02-19T00:42:59Z","updated_at":"2015-02-19T00:42:59Z","html_url":"https://github.com/sf-squirrels-2015/ph2-pA-week-1-passion-project/pull/25#discussion_r24956828","pull_request_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/pulls/25","_links":{"self":{"href":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/pulls/comments/24956828"},"html":{"href":"https://github.com/sf-squirrels-2015/ph2-pA-week-1-passion-project/pull/25#discussion_r24956828"},"pull_request":{"href":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/pulls/25"}}},"pull_request":{"url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/pulls/25","id":29113654,"html_url":"https://github.com/sf-squirrels-2015/ph2-pA-week-1-passion-project/pull/25","diff_url":"https://github.com/sf-squirrels-2015/ph2-pA-week-1-passion-project/pull/25.diff","patch_url":"https://github.com/sf-squirrels-2015/ph2-pA-week-1-passion-project/pull/25.patch","issue_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/issues/25","number":25,"state":"open","locked":false,"title":"PassionProject Week1","user":{"login":"lucasosouza","id":641561,"avatar_url":"https://avatars.githubusercontent.com/u/641561?v=3","gravatar_id":"","url":"https://api.github.com/users/lucasosouza","html_url":"https://github.com/lucasosouza","followers_url":"https://api.github.com/users/lucasosouza/followers","following_url":"https://api.github.com/users/lucasosouza/following{/other_user}","gists_url":"https://api.github.com/users/lucasosouza/gists{/gist_id}","starred_url":"https://api.github.com/users/lucasosouza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucasosouza/subscriptions","organizations_url":"https://api.github.com/users/lucasosouza/orgs","repos_url":"https://api.github.com/users/lucasosouza/repos","events_url":"https://api.github.com/users/lucasosouza/events{/privacy}","received_events_url":"https://api.github.com/users/lucasosouza/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-02-11T18:02:36Z","updated_at":"2015-02-19T00:42:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"41d9ba256f86aa81d82183ccd00c82404d0cc6c3","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/pulls/25/commits","review_comments_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/pulls/25/comments","review_comment_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/pulls/comments/{number}","comments_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/issues/25/comments","statuses_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/statuses/d4365b6373266ee3ae0eb2b6c8168caa31a232fd","head":{"label":"lucasosouza:master","ref":"master","sha":"d4365b6373266ee3ae0eb2b6c8168caa31a232fd","user":{"login":"lucasosouza","id":641561,"avatar_url":"https://avatars.githubusercontent.com/u/641561?v=3","gravatar_id":"","url":"https://api.github.com/users/lucasosouza","html_url":"https://github.com/lucasosouza","followers_url":"https://api.github.com/users/lucasosouza/followers","following_url":"https://api.github.com/users/lucasosouza/following{/other_user}","gists_url":"https://api.github.com/users/lucasosouza/gists{/gist_id}","starred_url":"https://api.github.com/users/lucasosouza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucasosouza/subscriptions","organizations_url":"https://api.github.com/users/lucasosouza/orgs","repos_url":"https://api.github.com/users/lucasosouza/repos","events_url":"https://api.github.com/users/lucasosouza/events{/privacy}","received_events_url":"https://api.github.com/users/lucasosouza/received_events","type":"User","site_admin":false},"repo":{"id":30661526,"name":"ph2-pA-week-1-passion-project","full_name":"lucasosouza/ph2-pA-week-1-passion-project","owner":{"login":"lucasosouza","id":641561,"avatar_url":"https://avatars.githubusercontent.com/u/641561?v=3","gravatar_id":"","url":"https://api.github.com/users/lucasosouza","html_url":"https://github.com/lucasosouza","followers_url":"https://api.github.com/users/lucasosouza/followers","following_url":"https://api.github.com/users/lucasosouza/following{/other_user}","gists_url":"https://api.github.com/users/lucasosouza/gists{/gist_id}","starred_url":"https://api.github.com/users/lucasosouza/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lucasosouza/subscriptions","organizations_url":"https://api.github.com/users/lucasosouza/orgs","repos_url":"https://api.github.com/users/lucasosouza/repos","events_url":"https://api.github.com/users/lucasosouza/events{/privacy}","received_events_url":"https://api.github.com/users/lucasosouza/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/lucasosouza/ph2-pA-week-1-passion-project","description":"","fork":true,"url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project","forks_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/forks","keys_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/teams","hooks_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/hooks","issue_events_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/issues/events{/number}","events_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/events","assignees_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/assignees{/user}","branches_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/branches{/branch}","tags_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/tags","blobs_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/statuses/{sha}","languages_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/languages","stargazers_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/stargazers","contributors_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/contributors","subscribers_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/subscribers","subscription_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/subscription","commits_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/issues/comments/{number}","contents_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/contents/{+path}","compare_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/merges","archive_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/downloads","issues_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/issues{/number}","pulls_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/pulls{/number}","milestones_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/milestones{/number}","notifications_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/labels{/name}","releases_url":"https://api.github.com/repos/lucasosouza/ph2-pA-week-1-passion-project/releases{/id}","created_at":"2015-02-11T17:59:18Z","updated_at":"2015-02-11T18:02:02Z","pushed_at":"2015-02-11T18:02:02Z","git_url":"git://github.com/lucasosouza/ph2-pA-week-1-passion-project.git","ssh_url":"git@github.com:lucasosouza/ph2-pA-week-1-passion-project.git","clone_url":"https://github.com/lucasosouza/ph2-pA-week-1-passion-project.git","svn_url":"https://github.com/lucasosouza/ph2-pA-week-1-passion-project","homepage":null,"size":1927,"stargazers_count":0,"watchers_count":0,"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":0,"default_branch":"master"}},"base":{"label":"sf-squirrels-2015:master","ref":"master","sha":"29609cb497d625caed0bec0fe0d03af9670828bc","user":{"login":"sf-squirrels-2015","id":10455711,"avatar_url":"https://avatars.githubusercontent.com/u/10455711?v=3","gravatar_id":"","url":"https://api.github.com/users/sf-squirrels-2015","html_url":"https://github.com/sf-squirrels-2015","followers_url":"https://api.github.com/users/sf-squirrels-2015/followers","following_url":"https://api.github.com/users/sf-squirrels-2015/following{/other_user}","gists_url":"https://api.github.com/users/sf-squirrels-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/sf-squirrels-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sf-squirrels-2015/subscriptions","organizations_url":"https://api.github.com/users/sf-squirrels-2015/orgs","repos_url":"https://api.github.com/users/sf-squirrels-2015/repos","events_url":"https://api.github.com/users/sf-squirrels-2015/events{/privacy}","received_events_url":"https://api.github.com/users/sf-squirrels-2015/received_events","type":"Organization","site_admin":false},"repo":{"id":30276334,"name":"ph2-pA-week-1-passion-project","full_name":"sf-squirrels-2015/ph2-pA-week-1-passion-project","owner":{"login":"sf-squirrels-2015","id":10455711,"avatar_url":"https://avatars.githubusercontent.com/u/10455711?v=3","gravatar_id":"","url":"https://api.github.com/users/sf-squirrels-2015","html_url":"https://github.com/sf-squirrels-2015","followers_url":"https://api.github.com/users/sf-squirrels-2015/followers","following_url":"https://api.github.com/users/sf-squirrels-2015/following{/other_user}","gists_url":"https://api.github.com/users/sf-squirrels-2015/gists{/gist_id}","starred_url":"https://api.github.com/users/sf-squirrels-2015/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sf-squirrels-2015/subscriptions","organizations_url":"https://api.github.com/users/sf-squirrels-2015/orgs","repos_url":"https://api.github.com/users/sf-squirrels-2015/repos","events_url":"https://api.github.com/users/sf-squirrels-2015/events{/privacy}","received_events_url":"https://api.github.com/users/sf-squirrels-2015/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sf-squirrels-2015/ph2-pA-week-1-passion-project","description":"","fork":false,"url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project","forks_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/forks","keys_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/teams","hooks_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/hooks","issue_events_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/issues/events{/number}","events_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/events","assignees_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/assignees{/user}","branches_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/branches{/branch}","tags_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/tags","blobs_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/git/refs{/sha}","trees_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/statuses/{sha}","languages_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/languages","stargazers_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/stargazers","contributors_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/contributors","subscribers_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/subscribers","subscription_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/subscription","commits_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/commits{/sha}","git_commits_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/git/commits{/sha}","comments_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/comments{/number}","issue_comment_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/issues/comments/{number}","contents_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/contents/{+path}","compare_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/merges","archive_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/downloads","issues_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/issues{/number}","pulls_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/pulls{/number}","milestones_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/milestones{/number}","notifications_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/labels{/name}","releases_url":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/releases{/id}","created_at":"2015-02-04T02:09:34Z","updated_at":"2015-02-04T02:09:34Z","pushed_at":"2015-02-07T21:33:49Z","git_url":"git://github.com/sf-squirrels-2015/ph2-pA-week-1-passion-project.git","ssh_url":"git@github.com:sf-squirrels-2015/ph2-pA-week-1-passion-project.git","clone_url":"https://github.com/sf-squirrels-2015/ph2-pA-week-1-passion-project.git","svn_url":"https://github.com/sf-squirrels-2015/ph2-pA-week-1-passion-project","homepage":null,"size":214,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":19,"mirror_url":null,"open_issues_count":20,"forks":19,"open_issues":20,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/pulls/25"},"html":{"href":"https://github.com/sf-squirrels-2015/ph2-pA-week-1-passion-project/pull/25"},"issue":{"href":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/issues/25"},"comments":{"href":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/issues/25/comments"},"review_comments":{"href":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/pulls/25/comments"},"review_comment":{"href":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/pulls/25/commits"},"statuses":{"href":"https://api.github.com/repos/sf-squirrels-2015/ph2-pA-week-1-passion-project/statuses/d4365b6373266ee3ae0eb2b6c8168caa31a232fd"}}}}