{"action":"created","comment":{"url":"https://api.github.com/repos/otwcode/otwarchive/pulls/comments/199524928","pull_request_review_id":133659664,"id":199524928,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDE5OTUyNDkyOA==","diff_hunk":"@@ -0,0 +1,222 @@\n+class Api::V2::BookmarksController < Api::V2::BaseController\n+  respond_to :json\n+\n+  # POST - search for bookmarks for this archivist\n+  def search\n+    archivist = User.find_by(login: params[:archivist])\n+    bookmarks = params[:bookmarks]\n+    status = :bad_request\n+\n+    archivist_bookmarks = Bookmark.where(pseud_id: archivist.default_pseud.id)\n+    results = bookmarks.map do |bookmark|\n+      found_result = {}\n+      found_result = check_archivist_bookmark(archivist, bookmark[:url], archivist_bookmarks) unless archivist_bookmarks.empty?\n+      \n+      bookmark_response(\n+        status: found_result[:bookmark_status] || :not_found,\n+        bookmark_url: found_result[:bookmark_url] || \"\",\n+        bookmark_id: bookmark[:id],\n+        original_url: bookmark[:url],\n+        messages: found_result[:bookmark_messages] || [\"No bookmark found for archivist \\\"#{archivist.login}\\\" and URL \\\"#{bookmark[:url]}\\\"\"]\n+      )\n+    end\n+\n+    messages = [\"Successfully searched bookmarks for archivist '#{archivist.login}'\"]\n+    render_api_response(status, messages, bookmarks: results)\n+  end\n+\n+  # POST - create a bookmark for this archivist\n+  def create\n+    archivist = User.find_by(login: params[:archivist])\n+    bookmarks = params[:bookmarks]\n+    bookmarks_responses = []\n+    @bookmarks = []\n+\n+    # check for top-level errors (not an archivist, no bookmarks...)\n+    status, messages = batch_errors(archivist, bookmarks)\n+\n+    if status == :ok\n+      # Flag error and successes\n+      @some_errors = @some_success = false\n+\n+      # Process the bookmarks\n+      archivist_bookmarks = Bookmark.where(pseud_id: archivist.default_pseud_id, bookmarkable_type: \"ExternalWork\")\n+      bookmarks.each do |bookmark|\n+        bookmarks_responses << create_bookmark(archivist, bookmark, archivist_bookmarks)\n+      end\n+\n+      # set final response code and message depending on the flags\n+      status = :bad_request if bookmarks_responses.any? { |r| [:ok, :created, :found].exclude?(r[:status]) }\n+      messages = response_message(messages)\n+    end\n+\n+    render_api_response(status, messages, bookmarks: bookmarks_responses)\n+  end\n+\n+  private\n+\n+  # Find bookmarks for this archivist\n+  def check_archivist_bookmark(archivist, original_url, archivist_bookmarks)\n+    current_bookmark_url = original_url\n+    archivist_bookmarks = archivist_bookmarks\n+                            .select { |b| b.bookmarkable.url == current_bookmark_url }","path":"app/controllers/api/v2/bookmarks_controller.rb","position":62,"original_position":62,"commit_id":"d9d5d8aa625e0f6e563369659c90a93431fff348","original_commit_id":"d9d5d8aa625e0f6e563369659c90a93431fff348","user":{"login":"houndci-bot","id":6697940,"node_id":"MDQ6VXNlcjY2OTc5NDA=","avatar_url":"https://avatars0.githubusercontent.com/u/6697940?v=4","gravatar_id":"","url":"https://api.github.com/users/houndci-bot","html_url":"https://github.com/houndci-bot","followers_url":"https://api.github.com/users/houndci-bot/followers","following_url":"https://api.github.com/users/houndci-bot/following{/other_user}","gists_url":"https://api.github.com/users/houndci-bot/gists{/gist_id}","starred_url":"https://api.github.com/users/houndci-bot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/houndci-bot/subscriptions","organizations_url":"https://api.github.com/users/houndci-bot/orgs","repos_url":"https://api.github.com/users/houndci-bot/repos","events_url":"https://api.github.com/users/houndci-bot/events{/privacy}","received_events_url":"https://api.github.com/users/houndci-bot/received_events","type":"User","site_admin":false},"body":"Layout/DotPosition: Place the . on the previous line, together with the method call receiver.<br>Layout/MultilineMethodCallIndentation: Align .select with archivist_bookmarks on line 61.","created_at":"2018-07-02T14:54:59Z","updated_at":"2018-07-02T14:55:01Z","html_url":"https://github.com/otwcode/otwarchive/pull/3105#discussion_r199524928","pull_request_url":"https://api.github.com/repos/otwcode/otwarchive/pulls/3105","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/otwcode/otwarchive/pulls/comments/199524928"},"html":{"href":"https://github.com/otwcode/otwarchive/pull/3105#discussion_r199524928"},"pull_request":{"href":"https://api.github.com/repos/otwcode/otwarchive/pulls/3105"}}},"pull_request":{"url":"https://api.github.com/repos/otwcode/otwarchive/pulls/3105","id":146621455,"node_id":"MDExOlB1bGxSZXF1ZXN0MTQ2NjIxNDU1","html_url":"https://github.com/otwcode/otwarchive/pull/3105","diff_url":"https://github.com/otwcode/otwarchive/pull/3105.diff","patch_url":"https://github.com/otwcode/otwarchive/pull/3105.patch","issue_url":"https://api.github.com/repos/otwcode/otwarchive/issues/3105","number":3105,"state":"open","locked":false,"title":"AO3-4625 Mass import API v2","user":{"login":"ariana-paris","id":1660785,"node_id":"MDQ6VXNlcjE2NjA3ODU=","avatar_url":"https://avatars1.githubusercontent.com/u/1660785?v=4","gravatar_id":"","url":"https://api.github.com/users/ariana-paris","html_url":"https://github.com/ariana-paris","followers_url":"https://api.github.com/users/ariana-paris/followers","following_url":"https://api.github.com/users/ariana-paris/following{/other_user}","gists_url":"https://api.github.com/users/ariana-paris/gists{/gist_id}","starred_url":"https://api.github.com/users/ariana-paris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ariana-paris/subscriptions","organizations_url":"https://api.github.com/users/ariana-paris/orgs","repos_url":"https://api.github.com/users/ariana-paris/repos","events_url":"https://api.github.com/users/ariana-paris/events{/privacy}","received_events_url":"https://api.github.com/users/ariana-paris/received_events","type":"User","site_admin":false},"body":"## Issue\r\n\r\nhttps://otwarchive.atlassian.net/browse/AO3-4625\r\n\r\n## Purpose\r\n\r\nThis rolls over the API to version 2 in order to introduce better named end points and clearer error messages.\r\n\r\n## Testing\r\n\r\nSee Jira comment.\r\n","created_at":"2017-10-14T21:07:16Z","updated_at":"2018-07-02T14:55:01Z","closed_at":null,"merged_at":null,"merge_commit_sha":"cb806f08718852d505ee1edde5f85f6a8a8b1257","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":122774326,"node_id":"MDU6TGFiZWwxMjI3NzQzMjY=","url":"https://api.github.com/repos/otwcode/otwarchive/labels/Reviewed:%20Needs%20Coder%20Action","name":"Reviewed: Needs Coder Action","color":"e11d21","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/otwcode/otwarchive/pulls/3105/commits","review_comments_url":"https://api.github.com/repos/otwcode/otwarchive/pulls/3105/comments","review_comment_url":"https://api.github.com/repos/otwcode/otwarchive/pulls/comments{/number}","comments_url":"https://api.github.com/repos/otwcode/otwarchive/issues/3105/comments","statuses_url":"https://api.github.com/repos/otwcode/otwarchive/statuses/d9d5d8aa625e0f6e563369659c90a93431fff348","head":{"label":"ariana-paris:AO3-4625-v2-r51","ref":"AO3-4625-v2-r51","sha":"d9d5d8aa625e0f6e563369659c90a93431fff348","user":{"login":"ariana-paris","id":1660785,"node_id":"MDQ6VXNlcjE2NjA3ODU=","avatar_url":"https://avatars1.githubusercontent.com/u/1660785?v=4","gravatar_id":"","url":"https://api.github.com/users/ariana-paris","html_url":"https://github.com/ariana-paris","followers_url":"https://api.github.com/users/ariana-paris/followers","following_url":"https://api.github.com/users/ariana-paris/following{/other_user}","gists_url":"https://api.github.com/users/ariana-paris/gists{/gist_id}","starred_url":"https://api.github.com/users/ariana-paris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ariana-paris/subscriptions","organizations_url":"https://api.github.com/users/ariana-paris/orgs","repos_url":"https://api.github.com/users/ariana-paris/repos","events_url":"https://api.github.com/users/ariana-paris/events{/privacy}","received_events_url":"https://api.github.com/users/ariana-paris/received_events","type":"User","site_admin":false},"repo":{"id":4213690,"node_id":"MDEwOlJlcG9zaXRvcnk0MjEzNjkw","name":"otwarchive","full_name":"ariana-paris/otwarchive","owner":{"login":"ariana-paris","id":1660785,"node_id":"MDQ6VXNlcjE2NjA3ODU=","avatar_url":"https://avatars1.githubusercontent.com/u/1660785?v=4","gravatar_id":"","url":"https://api.github.com/users/ariana-paris","html_url":"https://github.com/ariana-paris","followers_url":"https://api.github.com/users/ariana-paris/followers","following_url":"https://api.github.com/users/ariana-paris/following{/other_user}","gists_url":"https://api.github.com/users/ariana-paris/gists{/gist_id}","starred_url":"https://api.github.com/users/ariana-paris/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ariana-paris/subscriptions","organizations_url":"https://api.github.com/users/ariana-paris/orgs","repos_url":"https://api.github.com/users/ariana-paris/repos","events_url":"https://api.github.com/users/ariana-paris/events{/privacy}","received_events_url":"https://api.github.com/users/ariana-paris/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ariana-paris/otwarchive","description":"The Organization for Transformative Works (OTW) - Archive Of Our Own (AO3) Project","fork":true,"url":"https://api.github.com/repos/ariana-paris/otwarchive","forks_url":"https://api.github.com/repos/ariana-paris/otwarchive/forks","keys_url":"https://api.github.com/repos/ariana-paris/otwarchive/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ariana-paris/otwarchive/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ariana-paris/otwarchive/teams","hooks_url":"https://api.github.com/repos/ariana-paris/otwarchive/hooks","issue_events_url":"https://api.github.com/repos/ariana-paris/otwarchive/issues/events{/number}","events_url":"https://api.github.com/repos/ariana-paris/otwarchive/events","assignees_url":"https://api.github.com/repos/ariana-paris/otwarchive/assignees{/user}","branches_url":"https://api.github.com/repos/ariana-paris/otwarchive/branches{/branch}","tags_url":"https://api.github.com/repos/ariana-paris/otwarchive/tags","blobs_url":"https://api.github.com/repos/ariana-paris/otwarchive/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ariana-paris/otwarchive/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ariana-paris/otwarchive/git/refs{/sha}","trees_url":"https://api.github.com/repos/ariana-paris/otwarchive/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ariana-paris/otwarchive/statuses/{sha}","languages_url":"https://api.github.com/repos/ariana-paris/otwarchive/languages","stargazers_url":"https://api.github.com/repos/ariana-paris/otwarchive/stargazers","contributors_url":"https://api.github.com/repos/ariana-paris/otwarchive/contributors","subscribers_url":"https://api.github.com/repos/ariana-paris/otwarchive/subscribers","subscription_url":"https://api.github.com/repos/ariana-paris/otwarchive/subscription","commits_url":"https://api.github.com/repos/ariana-paris/otwarchive/commits{/sha}","git_commits_url":"https://api.github.com/repos/ariana-paris/otwarchive/git/commits{/sha}","comments_url":"https://api.github.com/repos/ariana-paris/otwarchive/comments{/number}","issue_comment_url":"https://api.github.com/repos/ariana-paris/otwarchive/issues/comments{/number}","contents_url":"https://api.github.com/repos/ariana-paris/otwarchive/contents/{+path}","compare_url":"https://api.github.com/repos/ariana-paris/otwarchive/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ariana-paris/otwarchive/merges","archive_url":"https://api.github.com/repos/ariana-paris/otwarchive/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ariana-paris/otwarchive/downloads","issues_url":"https://api.github.com/repos/ariana-paris/otwarchive/issues{/number}","pulls_url":"https://api.github.com/repos/ariana-paris/otwarchive/pulls{/number}","milestones_url":"https://api.github.com/repos/ariana-paris/otwarchive/milestones{/number}","notifications_url":"https://api.github.com/repos/ariana-paris/otwarchive/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ariana-paris/otwarchive/labels{/name}","releases_url":"https://api.github.com/repos/ariana-paris/otwarchive/releases{/id}","deployments_url":"https://api.github.com/repos/ariana-paris/otwarchive/deployments","created_at":"2012-05-03T12:27:42Z","updated_at":"2018-07-02T13:54:40Z","pushed_at":"2018-07-02T14:54:23Z","git_url":"git://github.com/ariana-paris/otwarchive.git","ssh_url":"git@github.com:ariana-paris/otwarchive.git","clone_url":"https://github.com/ariana-paris/otwarchive.git","svn_url":"https://github.com/ariana-paris/otwarchive","homepage":"http://transformativeworks.org/projects/archive","size":54736,"stargazers_count":1,"watchers_count":1,"language":"Ruby","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"otwcode:master","ref":"master","sha":"279e1ef0341285b53168b7d3e715ade3d6652943","user":{"login":"otwcode","id":408606,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwODYwNg==","avatar_url":"https://avatars2.githubusercontent.com/u/408606?v=4","gravatar_id":"","url":"https://api.github.com/users/otwcode","html_url":"https://github.com/otwcode","followers_url":"https://api.github.com/users/otwcode/followers","following_url":"https://api.github.com/users/otwcode/following{/other_user}","gists_url":"https://api.github.com/users/otwcode/gists{/gist_id}","starred_url":"https://api.github.com/users/otwcode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otwcode/subscriptions","organizations_url":"https://api.github.com/users/otwcode/orgs","repos_url":"https://api.github.com/users/otwcode/repos","events_url":"https://api.github.com/users/otwcode/events{/privacy}","received_events_url":"https://api.github.com/users/otwcode/received_events","type":"Organization","site_admin":false},"repo":{"id":1338040,"node_id":"MDEwOlJlcG9zaXRvcnkxMzM4MDQw","name":"otwarchive","full_name":"otwcode/otwarchive","owner":{"login":"otwcode","id":408606,"node_id":"MDEyOk9yZ2FuaXphdGlvbjQwODYwNg==","avatar_url":"https://avatars2.githubusercontent.com/u/408606?v=4","gravatar_id":"","url":"https://api.github.com/users/otwcode","html_url":"https://github.com/otwcode","followers_url":"https://api.github.com/users/otwcode/followers","following_url":"https://api.github.com/users/otwcode/following{/other_user}","gists_url":"https://api.github.com/users/otwcode/gists{/gist_id}","starred_url":"https://api.github.com/users/otwcode/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/otwcode/subscriptions","organizations_url":"https://api.github.com/users/otwcode/orgs","repos_url":"https://api.github.com/users/otwcode/repos","events_url":"https://api.github.com/users/otwcode/events{/privacy}","received_events_url":"https://api.github.com/users/otwcode/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/otwcode/otwarchive","description":"The Organization for Transformative Works (OTW) - Archive Of Our Own (AO3) Project","fork":false,"url":"https://api.github.com/repos/otwcode/otwarchive","forks_url":"https://api.github.com/repos/otwcode/otwarchive/forks","keys_url":"https://api.github.com/repos/otwcode/otwarchive/keys{/key_id}","collaborators_url":"https://api.github.com/repos/otwcode/otwarchive/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/otwcode/otwarchive/teams","hooks_url":"https://api.github.com/repos/otwcode/otwarchive/hooks","issue_events_url":"https://api.github.com/repos/otwcode/otwarchive/issues/events{/number}","events_url":"https://api.github.com/repos/otwcode/otwarchive/events","assignees_url":"https://api.github.com/repos/otwcode/otwarchive/assignees{/user}","branches_url":"https://api.github.com/repos/otwcode/otwarchive/branches{/branch}","tags_url":"https://api.github.com/repos/otwcode/otwarchive/tags","blobs_url":"https://api.github.com/repos/otwcode/otwarchive/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/otwcode/otwarchive/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/otwcode/otwarchive/git/refs{/sha}","trees_url":"https://api.github.com/repos/otwcode/otwarchive/git/trees{/sha}","statuses_url":"https://api.github.com/repos/otwcode/otwarchive/statuses/{sha}","languages_url":"https://api.github.com/repos/otwcode/otwarchive/languages","stargazers_url":"https://api.github.com/repos/otwcode/otwarchive/stargazers","contributors_url":"https://api.github.com/repos/otwcode/otwarchive/contributors","subscribers_url":"https://api.github.com/repos/otwcode/otwarchive/subscribers","subscription_url":"https://api.github.com/repos/otwcode/otwarchive/subscription","commits_url":"https://api.github.com/repos/otwcode/otwarchive/commits{/sha}","git_commits_url":"https://api.github.com/repos/otwcode/otwarchive/git/commits{/sha}","comments_url":"https://api.github.com/repos/otwcode/otwarchive/comments{/number}","issue_comment_url":"https://api.github.com/repos/otwcode/otwarchive/issues/comments{/number}","contents_url":"https://api.github.com/repos/otwcode/otwarchive/contents/{+path}","compare_url":"https://api.github.com/repos/otwcode/otwarchive/compare/{base}...{head}","merges_url":"https://api.github.com/repos/otwcode/otwarchive/merges","archive_url":"https://api.github.com/repos/otwcode/otwarchive/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/otwcode/otwarchive/downloads","issues_url":"https://api.github.com/repos/otwcode/otwarchive/issues{/number}","pulls_url":"https://api.github.com/repos/otwcode/otwarchive/pulls{/number}","milestones_url":"https://api.github.com/repos/otwcode/otwarchive/milestones{/number}","notifications_url":"https://api.github.com/repos/otwcode/otwarchive/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/otwcode/otwarchive/labels{/name}","releases_url":"https://api.github.com/repos/otwcode/otwarchive/releases{/id}","deployments_url":"https://api.github.com/repos/otwcode/otwarchive/deployments","created_at":"2011-02-07T14:50:58Z","updated_at":"2018-07-02T03:45:49Z","pushed_at":"2018-07-02T14:54:26Z","git_url":"git://github.com/otwcode/otwarchive.git","ssh_url":"git@github.com:otwcode/otwarchive.git","clone_url":"https://github.com/otwcode/otwarchive.git","svn_url":"https://github.com/otwcode/otwarchive","homepage":"http://www.transformativeworks.org/archive_of_our_own/","size":54446,"stargazers_count":339,"watchers_count":339,"language":"Ruby","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":187,"mirror_url":null,"archived":false,"open_issues_count":120,"license":{"key":"gpl-2.0","name":"GNU General Public License v2.0","spdx_id":"GPL-2.0","url":"https://api.github.com/licenses/gpl-2.0","node_id":"MDc6TGljZW5zZTg="},"forks":187,"open_issues":120,"watchers":339,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/otwcode/otwarchive/pulls/3105"},"html":{"href":"https://github.com/otwcode/otwarchive/pull/3105"},"issue":{"href":"https://api.github.com/repos/otwcode/otwarchive/issues/3105"},"comments":{"href":"https://api.github.com/repos/otwcode/otwarchive/issues/3105/comments"},"review_comments":{"href":"https://api.github.com/repos/otwcode/otwarchive/pulls/3105/comments"},"review_comment":{"href":"https://api.github.com/repos/otwcode/otwarchive/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/otwcode/otwarchive/pulls/3105/commits"},"statuses":{"href":"https://api.github.com/repos/otwcode/otwarchive/statuses/d9d5d8aa625e0f6e563369659c90a93431fff348"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"houndci-bot"}}