{"action":"created","comment":{"url":"https://api.github.com/repos/alphagov/support-api/pulls/comments/22727852","id":22727852,"diff_hunk":"@@ -0,0 +1,15 @@\n+require 'content_api/enhanced_content_api'\n+\n+class ContentItem < ActiveRecord::Base\n+  has_and_belongs_to_many :organisations\n+\n+  validates :path, presence: true\n+\n+  before_create :fetch_organisations\n+\n+  private\n+  def fetch_organisations\n+    orgs_data = SupportApi::enhanced_content_api.organisations_for(path)\n+    self.organisations = orgs_data.map {|org_info| Organisation.where(org_info).first_or_create! }","path":"app/models/content_item.rb","position":null,"original_position":13,"commit_id":"790fb88c171460282cdfe2721ccd5e381fe63b98","original_commit_id":"4a1e2996663d3e242caa1d1d386c45f2568b79a9","user":{"login":"benilovj","id":23801,"avatar_url":"https://avatars.githubusercontent.com/u/23801?v=3","gravatar_id":"","url":"https://api.github.com/users/benilovj","html_url":"https://github.com/benilovj","followers_url":"https://api.github.com/users/benilovj/followers","following_url":"https://api.github.com/users/benilovj/following{/other_user}","gists_url":"https://api.github.com/users/benilovj/gists{/gist_id}","starred_url":"https://api.github.com/users/benilovj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benilovj/subscriptions","organizations_url":"https://api.github.com/users/benilovj/orgs","repos_url":"https://api.github.com/users/benilovj/repos","events_url":"https://api.github.com/users/benilovj/events{/privacy}","received_events_url":"https://api.github.com/users/benilovj/received_events","type":"User","site_admin":false},"body":"fixed and force-pushed.","created_at":"2015-01-09T17:03:29Z","updated_at":"2015-01-09T17:03:29Z","html_url":"https://github.com/alphagov/support-api/pull/26#discussion_r22727852","pull_request_url":"https://api.github.com/repos/alphagov/support-api/pulls/26","_links":{"self":{"href":"https://api.github.com/repos/alphagov/support-api/pulls/comments/22727852"},"html":{"href":"https://github.com/alphagov/support-api/pull/26#discussion_r22727852"},"pull_request":{"href":"https://api.github.com/repos/alphagov/support-api/pulls/26"}}},"pull_request":{"url":"https://api.github.com/repos/alphagov/support-api/pulls/26","id":27040784,"html_url":"https://github.com/alphagov/support-api/pull/26","diff_url":"https://github.com/alphagov/support-api/pull/26.diff","patch_url":"https://github.com/alphagov/support-api/pull/26.patch","issue_url":"https://api.github.com/repos/alphagov/support-api/issues/26","number":26,"state":"open","locked":false,"title":"Identify content items, organisations for each problem report","user":{"login":"benilovj","id":23801,"avatar_url":"https://avatars.githubusercontent.com/u/23801?v=3","gravatar_id":"","url":"https://api.github.com/users/benilovj","html_url":"https://github.com/benilovj","followers_url":"https://api.github.com/users/benilovj/followers","following_url":"https://api.github.com/users/benilovj/following{/other_user}","gists_url":"https://api.github.com/users/benilovj/gists{/gist_id}","starred_url":"https://api.github.com/users/benilovj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benilovj/subscriptions","organizations_url":"https://api.github.com/users/benilovj/orgs","repos_url":"https://api.github.com/users/benilovj/repos","events_url":"https://api.github.com/users/benilovj/events{/privacy}","received_events_url":"https://api.github.com/users/benilovj/received_events","type":"User","site_admin":false},"body":"In order to present relevant anonymous feedback to users in departments and ALBs, we need to know which organisation is interested in a particular piece of feedback. This can be done by looking up at the orgs that relate to the piece of content that originated the problem report.\r\n\r\nThe org information is retrieved from the Content API and persisted; this saves having to fetch a list of all content relating to a particular org, and trying to get the feedback for each one of those paths.\r\n\r\nMore details about the implementation in the commit messages.\r\n","created_at":"2015-01-08T16:38:39Z","updated_at":"2015-01-09T17:03:29Z","closed_at":null,"merged_at":null,"merge_commit_sha":"70301e297b293e275a5ea0564071a251375d6c3f","assignee":{"login":"danielroseman","id":131395,"avatar_url":"https://avatars.githubusercontent.com/u/131395?v=3","gravatar_id":"","url":"https://api.github.com/users/danielroseman","html_url":"https://github.com/danielroseman","followers_url":"https://api.github.com/users/danielroseman/followers","following_url":"https://api.github.com/users/danielroseman/following{/other_user}","gists_url":"https://api.github.com/users/danielroseman/gists{/gist_id}","starred_url":"https://api.github.com/users/danielroseman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/danielroseman/subscriptions","organizations_url":"https://api.github.com/users/danielroseman/orgs","repos_url":"https://api.github.com/users/danielroseman/repos","events_url":"https://api.github.com/users/danielroseman/events{/privacy}","received_events_url":"https://api.github.com/users/danielroseman/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/alphagov/support-api/pulls/26/commits","review_comments_url":"https://api.github.com/repos/alphagov/support-api/pulls/26/comments","review_comment_url":"https://api.github.com/repos/alphagov/support-api/pulls/comments/{number}","comments_url":"https://api.github.com/repos/alphagov/support-api/issues/26/comments","statuses_url":"https://api.github.com/repos/alphagov/support-api/statuses/790fb88c171460282cdfe2721ccd5e381fe63b98","head":{"label":"alphagov:identify-content-item","ref":"identify-content-item","sha":"790fb88c171460282cdfe2721ccd5e381fe63b98","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":20967866,"name":"support-api","full_name":"alphagov/support-api","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/support-api","description":"An API for processing GOV.UK named requests and anonymous feedback","fork":false,"url":"https://api.github.com/repos/alphagov/support-api","forks_url":"https://api.github.com/repos/alphagov/support-api/forks","keys_url":"https://api.github.com/repos/alphagov/support-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/support-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/support-api/teams","hooks_url":"https://api.github.com/repos/alphagov/support-api/hooks","issue_events_url":"https://api.github.com/repos/alphagov/support-api/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/support-api/events","assignees_url":"https://api.github.com/repos/alphagov/support-api/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/support-api/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/support-api/tags","blobs_url":"https://api.github.com/repos/alphagov/support-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/support-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/support-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/support-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/support-api/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/support-api/languages","stargazers_url":"https://api.github.com/repos/alphagov/support-api/stargazers","contributors_url":"https://api.github.com/repos/alphagov/support-api/contributors","subscribers_url":"https://api.github.com/repos/alphagov/support-api/subscribers","subscription_url":"https://api.github.com/repos/alphagov/support-api/subscription","commits_url":"https://api.github.com/repos/alphagov/support-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/support-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/support-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/support-api/issues/comments/{number}","contents_url":"https://api.github.com/repos/alphagov/support-api/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/support-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/support-api/merges","archive_url":"https://api.github.com/repos/alphagov/support-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/support-api/downloads","issues_url":"https://api.github.com/repos/alphagov/support-api/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/support-api/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/support-api/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/support-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/support-api/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/support-api/releases{/id}","created_at":"2014-06-18T15:43:38Z","updated_at":"2015-01-06T18:29:55Z","pushed_at":"2015-01-09T17:03:05Z","git_url":"git://github.com/alphagov/support-api.git","ssh_url":"git@github.com:alphagov/support-api.git","clone_url":"https://github.com/alphagov/support-api.git","svn_url":"https://github.com/alphagov/support-api","homepage":"","size":739,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"base":{"label":"alphagov:master","ref":"master","sha":"8a0270a47a3ab003371d1ee66b02a7f772beba26","user":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"repo":{"id":20967866,"name":"support-api","full_name":"alphagov/support-api","owner":{"login":"alphagov","id":596977,"avatar_url":"https://avatars.githubusercontent.com/u/596977?v=3","gravatar_id":"","url":"https://api.github.com/users/alphagov","html_url":"https://github.com/alphagov","followers_url":"https://api.github.com/users/alphagov/followers","following_url":"https://api.github.com/users/alphagov/following{/other_user}","gists_url":"https://api.github.com/users/alphagov/gists{/gist_id}","starred_url":"https://api.github.com/users/alphagov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/alphagov/subscriptions","organizations_url":"https://api.github.com/users/alphagov/orgs","repos_url":"https://api.github.com/users/alphagov/repos","events_url":"https://api.github.com/users/alphagov/events{/privacy}","received_events_url":"https://api.github.com/users/alphagov/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/alphagov/support-api","description":"An API for processing GOV.UK named requests and anonymous feedback","fork":false,"url":"https://api.github.com/repos/alphagov/support-api","forks_url":"https://api.github.com/repos/alphagov/support-api/forks","keys_url":"https://api.github.com/repos/alphagov/support-api/keys{/key_id}","collaborators_url":"https://api.github.com/repos/alphagov/support-api/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/alphagov/support-api/teams","hooks_url":"https://api.github.com/repos/alphagov/support-api/hooks","issue_events_url":"https://api.github.com/repos/alphagov/support-api/issues/events{/number}","events_url":"https://api.github.com/repos/alphagov/support-api/events","assignees_url":"https://api.github.com/repos/alphagov/support-api/assignees{/user}","branches_url":"https://api.github.com/repos/alphagov/support-api/branches{/branch}","tags_url":"https://api.github.com/repos/alphagov/support-api/tags","blobs_url":"https://api.github.com/repos/alphagov/support-api/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/alphagov/support-api/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/alphagov/support-api/git/refs{/sha}","trees_url":"https://api.github.com/repos/alphagov/support-api/git/trees{/sha}","statuses_url":"https://api.github.com/repos/alphagov/support-api/statuses/{sha}","languages_url":"https://api.github.com/repos/alphagov/support-api/languages","stargazers_url":"https://api.github.com/repos/alphagov/support-api/stargazers","contributors_url":"https://api.github.com/repos/alphagov/support-api/contributors","subscribers_url":"https://api.github.com/repos/alphagov/support-api/subscribers","subscription_url":"https://api.github.com/repos/alphagov/support-api/subscription","commits_url":"https://api.github.com/repos/alphagov/support-api/commits{/sha}","git_commits_url":"https://api.github.com/repos/alphagov/support-api/git/commits{/sha}","comments_url":"https://api.github.com/repos/alphagov/support-api/comments{/number}","issue_comment_url":"https://api.github.com/repos/alphagov/support-api/issues/comments/{number}","contents_url":"https://api.github.com/repos/alphagov/support-api/contents/{+path}","compare_url":"https://api.github.com/repos/alphagov/support-api/compare/{base}...{head}","merges_url":"https://api.github.com/repos/alphagov/support-api/merges","archive_url":"https://api.github.com/repos/alphagov/support-api/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/alphagov/support-api/downloads","issues_url":"https://api.github.com/repos/alphagov/support-api/issues{/number}","pulls_url":"https://api.github.com/repos/alphagov/support-api/pulls{/number}","milestones_url":"https://api.github.com/repos/alphagov/support-api/milestones{/number}","notifications_url":"https://api.github.com/repos/alphagov/support-api/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/alphagov/support-api/labels{/name}","releases_url":"https://api.github.com/repos/alphagov/support-api/releases{/id}","created_at":"2014-06-18T15:43:38Z","updated_at":"2015-01-06T18:29:55Z","pushed_at":"2015-01-09T17:03:05Z","git_url":"git://github.com/alphagov/support-api.git","ssh_url":"git@github.com:alphagov/support-api.git","clone_url":"https://github.com/alphagov/support-api.git","svn_url":"https://github.com/alphagov/support-api","homepage":"","size":739,"stargazers_count":1,"watchers_count":1,"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":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/alphagov/support-api/pulls/26"},"html":{"href":"https://github.com/alphagov/support-api/pull/26"},"issue":{"href":"https://api.github.com/repos/alphagov/support-api/issues/26"},"comments":{"href":"https://api.github.com/repos/alphagov/support-api/issues/26/comments"},"review_comments":{"href":"https://api.github.com/repos/alphagov/support-api/pulls/26/comments"},"review_comment":{"href":"https://api.github.com/repos/alphagov/support-api/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/alphagov/support-api/pulls/26/commits"},"statuses":{"href":"https://api.github.com/repos/alphagov/support-api/statuses/790fb88c171460282cdfe2721ccd5e381fe63b98"}}}}