{"action":"created","comment":{"url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/comments/29004479","id":29004479,"diff_hunk":"@@ -0,0 +1,41 @@\n+class Bill < ActiveRecord::Base\n+  has_many :sponsorships\n+  has_many :cosponsors, -> { merge(Sponsorship.cosponsored) }, through: :sponsorships, source: :legislator\n+  has_one :authorship, -> { merge(Sponsorship.sponsored) }, class_name: 'Sponsorship'\n+  has_one :sponsor, through: :authorship, source: :legislator\n+\n+  validates :bill_id, uniqueness: true\n+\n+  def self.fetch(bill_id:)\n+    if results = Integration::Sunlight.get_bill(bill_id:  bill_id)\n+      create_or_update(results.deep_symbolize_keys)\n+    end\n+  end\n+\n+  def self.create_or_update(hash)\n+    bill_id       = hash.delete(:bill_id)\n+    sponsor_id    = hash.delete(:sponsor_id)","path":"app/models/bill.rb","position":17,"original_position":17,"commit_id":"9f33fc20cda324f1f74518a08ed83bb6d0ce4b71","original_commit_id":"9f33fc20cda324f1f74518a08ed83bb6d0ce4b71","user":{"login":"houndci","id":6697940,"avatar_url":"https://avatars.githubusercontent.com/u/6697940?v=3","gravatar_id":"","url":"https://api.github.com/users/houndci","html_url":"https://github.com/houndci","followers_url":"https://api.github.com/users/houndci/followers","following_url":"https://api.github.com/users/houndci/following{/other_user}","gists_url":"https://api.github.com/users/houndci/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci/subscriptions","organizations_url":"https://api.github.com/users/houndci/orgs","repos_url":"https://api.github.com/users/houndci/repos","events_url":"https://api.github.com/users/houndci/events{/privacy}","received_events_url":"https://api.github.com/users/houndci/received_events","type":"User","site_admin":false},"body":"Unnecessary spacing detected.","created_at":"2015-04-23T21:17:44Z","updated_at":"2015-04-23T21:17:44Z","html_url":"https://github.com/MayOneUS/mayday-2.0-backend/pull/50#discussion_r29004479","pull_request_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/50","_links":{"self":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/comments/29004479"},"html":{"href":"https://github.com/MayOneUS/mayday-2.0-backend/pull/50#discussion_r29004479"},"pull_request":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/50"}}},"pull_request":{"url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/50","id":33997781,"html_url":"https://github.com/MayOneUS/mayday-2.0-backend/pull/50","diff_url":"https://github.com/MayOneUS/mayday-2.0-backend/pull/50.diff","patch_url":"https://github.com/MayOneUS/mayday-2.0-backend/pull/50.patch","issue_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/50","number":50,"state":"open","locked":false,"title":"add bills, sponsorships, and sunlight integration","user":{"login":"turino","id":9420188,"avatar_url":"https://avatars.githubusercontent.com/u/9420188?v=3","gravatar_id":"","url":"https://api.github.com/users/turino","html_url":"https://github.com/turino","followers_url":"https://api.github.com/users/turino/followers","following_url":"https://api.github.com/users/turino/following{/other_user}","gists_url":"https://api.github.com/users/turino/gists{/gist_id}","starred_url":"https://api.github.com/users/turino/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/turino/subscriptions","organizations_url":"https://api.github.com/users/turino/orgs","repos_url":"https://api.github.com/users/turino/repos","events_url":"https://api.github.com/users/turino/events{/privacy}","received_events_url":"https://api.github.com/users/turino/received_events","type":"User","site_admin":false},"body":"can now do `Bill.fetch(bill_id: bill_id)` to fetch a bill from sunlight with associated sponsor/cosponsors\r\n\r\nNote: this currently silently ignores any legislator not in the db -- i.e., there's no code to handle unknown `bioguide_id`\r\n\r\nTo do: better tests in bill_spec.rb (right now the test for `fetch` covers everything, but should be broken out into tests for each method called in `create_or_update`","created_at":"2015-04-23T21:17:37Z","updated_at":"2015-04-23T21:17:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1f96446acc4b401f46c661976936b2b898a27abb","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/50/commits","review_comments_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/50/comments","review_comment_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/comments{/number}","comments_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/50/comments","statuses_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/statuses/9f33fc20cda324f1f74518a08ed83bb6d0ce4b71","head":{"label":"MayOneUS:jt-bills","ref":"jt-bills","sha":"9f33fc20cda324f1f74518a08ed83bb6d0ce4b71","user":{"login":"MayOneUS","id":7469720,"avatar_url":"https://avatars.githubusercontent.com/u/7469720?v=3","gravatar_id":"","url":"https://api.github.com/users/MayOneUS","html_url":"https://github.com/MayOneUS","followers_url":"https://api.github.com/users/MayOneUS/followers","following_url":"https://api.github.com/users/MayOneUS/following{/other_user}","gists_url":"https://api.github.com/users/MayOneUS/gists{/gist_id}","starred_url":"https://api.github.com/users/MayOneUS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MayOneUS/subscriptions","organizations_url":"https://api.github.com/users/MayOneUS/orgs","repos_url":"https://api.github.com/users/MayOneUS/repos","events_url":"https://api.github.com/users/MayOneUS/events{/privacy}","received_events_url":"https://api.github.com/users/MayOneUS/received_events","type":"Organization","site_admin":false},"repo":{"id":29715441,"name":"mayday-2.0-backend","full_name":"MayOneUS/mayday-2.0-backend","owner":{"login":"MayOneUS","id":7469720,"avatar_url":"https://avatars.githubusercontent.com/u/7469720?v=3","gravatar_id":"","url":"https://api.github.com/users/MayOneUS","html_url":"https://github.com/MayOneUS","followers_url":"https://api.github.com/users/MayOneUS/followers","following_url":"https://api.github.com/users/MayOneUS/following{/other_user}","gists_url":"https://api.github.com/users/MayOneUS/gists{/gist_id}","starred_url":"https://api.github.com/users/MayOneUS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MayOneUS/subscriptions","organizations_url":"https://api.github.com/users/MayOneUS/orgs","repos_url":"https://api.github.com/users/MayOneUS/repos","events_url":"https://api.github.com/users/MayOneUS/events{/privacy}","received_events_url":"https://api.github.com/users/MayOneUS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MayOneUS/mayday-2.0-backend","description":"The API-driven next generation MADAY.us site","fork":false,"url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend","forks_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/forks","keys_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/teams","hooks_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/hooks","issue_events_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/events{/number}","events_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/events","assignees_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/assignees{/user}","branches_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/branches{/branch}","tags_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/tags","blobs_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/languages","stargazers_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/stargazers","contributors_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/contributors","subscribers_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/subscribers","subscription_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/subscription","commits_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/contents/{+path}","compare_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/merges","archive_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/downloads","issues_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues{/number}","pulls_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/labels{/name}","releases_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/releases{/id}","created_at":"2015-01-23T03:50:45Z","updated_at":"2015-04-16T16:39:05Z","pushed_at":"2015-04-23T21:17:37Z","git_url":"git://github.com/MayOneUS/mayday-2.0-backend.git","ssh_url":"git@github.com:MayOneUS/mayday-2.0-backend.git","clone_url":"https://github.com/MayOneUS/mayday-2.0-backend.git","svn_url":"https://github.com/MayOneUS/mayday-2.0-backend","homepage":null,"size":3279,"stargazers_count":2,"watchers_count":2,"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":2,"default_branch":"master"}},"base":{"label":"MayOneUS:m2","ref":"m2","sha":"7976a7d8511449b8f900b65cc190211bc838fd12","user":{"login":"MayOneUS","id":7469720,"avatar_url":"https://avatars.githubusercontent.com/u/7469720?v=3","gravatar_id":"","url":"https://api.github.com/users/MayOneUS","html_url":"https://github.com/MayOneUS","followers_url":"https://api.github.com/users/MayOneUS/followers","following_url":"https://api.github.com/users/MayOneUS/following{/other_user}","gists_url":"https://api.github.com/users/MayOneUS/gists{/gist_id}","starred_url":"https://api.github.com/users/MayOneUS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MayOneUS/subscriptions","organizations_url":"https://api.github.com/users/MayOneUS/orgs","repos_url":"https://api.github.com/users/MayOneUS/repos","events_url":"https://api.github.com/users/MayOneUS/events{/privacy}","received_events_url":"https://api.github.com/users/MayOneUS/received_events","type":"Organization","site_admin":false},"repo":{"id":29715441,"name":"mayday-2.0-backend","full_name":"MayOneUS/mayday-2.0-backend","owner":{"login":"MayOneUS","id":7469720,"avatar_url":"https://avatars.githubusercontent.com/u/7469720?v=3","gravatar_id":"","url":"https://api.github.com/users/MayOneUS","html_url":"https://github.com/MayOneUS","followers_url":"https://api.github.com/users/MayOneUS/followers","following_url":"https://api.github.com/users/MayOneUS/following{/other_user}","gists_url":"https://api.github.com/users/MayOneUS/gists{/gist_id}","starred_url":"https://api.github.com/users/MayOneUS/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/MayOneUS/subscriptions","organizations_url":"https://api.github.com/users/MayOneUS/orgs","repos_url":"https://api.github.com/users/MayOneUS/repos","events_url":"https://api.github.com/users/MayOneUS/events{/privacy}","received_events_url":"https://api.github.com/users/MayOneUS/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/MayOneUS/mayday-2.0-backend","description":"The API-driven next generation MADAY.us site","fork":false,"url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend","forks_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/forks","keys_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/keys{/key_id}","collaborators_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/teams","hooks_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/hooks","issue_events_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/events{/number}","events_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/events","assignees_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/assignees{/user}","branches_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/branches{/branch}","tags_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/tags","blobs_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/refs{/sha}","trees_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/trees{/sha}","statuses_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/statuses/{sha}","languages_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/languages","stargazers_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/stargazers","contributors_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/contributors","subscribers_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/subscribers","subscription_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/subscription","commits_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/commits{/sha}","git_commits_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/git/commits{/sha}","comments_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/comments{/number}","issue_comment_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/comments{/number}","contents_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/contents/{+path}","compare_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/compare/{base}...{head}","merges_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/merges","archive_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/downloads","issues_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues{/number}","pulls_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls{/number}","milestones_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/milestones{/number}","notifications_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/labels{/name}","releases_url":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/releases{/id}","created_at":"2015-01-23T03:50:45Z","updated_at":"2015-04-16T16:39:05Z","pushed_at":"2015-04-23T21:17:37Z","git_url":"git://github.com/MayOneUS/mayday-2.0-backend.git","ssh_url":"git@github.com:MayOneUS/mayday-2.0-backend.git","clone_url":"https://github.com/MayOneUS/mayday-2.0-backend.git","svn_url":"https://github.com/MayOneUS/mayday-2.0-backend","homepage":null,"size":3279,"stargazers_count":2,"watchers_count":2,"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":2,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/50"},"html":{"href":"https://github.com/MayOneUS/mayday-2.0-backend/pull/50"},"issue":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/50"},"comments":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/issues/50/comments"},"review_comments":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/50/comments"},"review_comment":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/pulls/50/commits"},"statuses":{"href":"https://api.github.com/repos/MayOneUS/mayday-2.0-backend/statuses/9f33fc20cda324f1f74518a08ed83bb6d0ce4b71"}}}}