{"action":"created","comment":{"url":"https://api.github.com/repos/sys-devel-d/pimp/pulls/comments/90978988","pull_request_review_id":11492003,"id":90978988,"diff_hunk":"@@ -67,4 +71,44 @@ public void addEvent(@Valid @RequestBody Event event, @PathVariable String calen\n     }\n   }\n \n+  @PreAuthorize(\"#oauth2.hasScope('user_actions')\")\n+  @RequestMapping(method = PUT, path = \"/event/{eventKey}\")\n+  public void editEvent(@Valid @RequestBody Event event, Principal principal) {\n+    Optional<Calendar> optionalCalendar =\n+        calendarService.getEventContainingCalendarByUserName(principal.getName(), event.getKey());\n+\n+    if (!optionalCalendar.isPresent()) {\n+      throw new EntityNotFoundException(\"An event with the key \" + event.getKey() +\n+          \" does not exist for the user\");\n+    } else {\n+      List<Event> events = optionalCalendar.get().getEvents()\n+        .stream()\n+        .map(aEvent -> aEvent.getKey().equals(event.getKey()) ? event : aEvent)\n+        .collect(Collectors.toList());\n+      Calendar calendar = optionalCalendar.get();\n+      calendar.setEvents(events);\n+      calendarService.save(calendar);\n+    }\n+  }\n+\n+  @PreAuthorize(\"#oauth2.hasScope('user_actions')\")\n+  @RequestMapping(method = DELETE, path = \"/event/{eventKey}\")\n+  public void deleteEvent(@Valid @RequestBody Event event, Principal principal) {\n+    Optional<Calendar> optionalCalendar =\n+        calendarService.getEventContainingCalendarByUserName(principal.getName(), event.getKey());","path":"src/main/java/com/pimp/controller/CalendarController.java","position":48,"original_position":48,"commit_id":"2117bcf72dfa08a2d67ce048e9539099d08527e2","original_commit_id":"2117bcf72dfa08a2d67ce048e9539099d08527e2","user":{"login":"haffla","id":2844304,"avatar_url":"https://avatars.githubusercontent.com/u/2844304?v=3","gravatar_id":"","url":"https://api.github.com/users/haffla","html_url":"https://github.com/haffla","followers_url":"https://api.github.com/users/haffla/followers","following_url":"https://api.github.com/users/haffla/following{/other_user}","gists_url":"https://api.github.com/users/haffla/gists{/gist_id}","starred_url":"https://api.github.com/users/haffla/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/haffla/subscriptions","organizations_url":"https://api.github.com/users/haffla/orgs","repos_url":"https://api.github.com/users/haffla/repos","events_url":"https://api.github.com/users/haffla/events{/privacy}","received_events_url":"https://api.github.com/users/haffla/received_events","type":"User","site_admin":false},"body":"Especially because `getEventContainingCalendarByUserName()` calls `getCalendarsByUser()` which queries ALL calendars from the database and let's the JVM filter the results instead of letting MongoDB (which probably is much better at it) do the gruntwork of filtering.","created_at":"2016-12-05T23:18:58Z","updated_at":"2016-12-05T23:18:58Z","html_url":"https://github.com/sys-devel-d/pimp/pull/22#discussion_r90978988","pull_request_url":"https://api.github.com/repos/sys-devel-d/pimp/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/sys-devel-d/pimp/pulls/comments/90978988"},"html":{"href":"https://github.com/sys-devel-d/pimp/pull/22#discussion_r90978988"},"pull_request":{"href":"https://api.github.com/repos/sys-devel-d/pimp/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/sys-devel-d/pimp/pulls/22","id":96606530,"html_url":"https://github.com/sys-devel-d/pimp/pull/22","diff_url":"https://github.com/sys-devel-d/pimp/pull/22.diff","patch_url":"https://github.com/sys-devel-d/pimp/pull/22.patch","issue_url":"https://api.github.com/repos/sys-devel-d/pimp/issues/22","number":22,"state":"open","locked":false,"title":"Adds routes for editing and deleting events.","user":{"login":"jufi","id":2759114,"avatar_url":"https://avatars.githubusercontent.com/u/2759114?v=3","gravatar_id":"","url":"https://api.github.com/users/jufi","html_url":"https://github.com/jufi","followers_url":"https://api.github.com/users/jufi/followers","following_url":"https://api.github.com/users/jufi/following{/other_user}","gists_url":"https://api.github.com/users/jufi/gists{/gist_id}","starred_url":"https://api.github.com/users/jufi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jufi/subscriptions","organizations_url":"https://api.github.com/users/jufi/orgs","repos_url":"https://api.github.com/users/jufi/repos","events_url":"https://api.github.com/users/jufi/events{/privacy}","received_events_url":"https://api.github.com/users/jufi/received_events","type":"User","site_admin":false},"body":"","created_at":"2016-12-05T20:50:18Z","updated_at":"2016-12-05T23:18:58Z","closed_at":null,"merged_at":null,"merge_commit_sha":"97f358f4df71c937f655947d46ce21940dcfc38c","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/sys-devel-d/pimp/pulls/22/commits","review_comments_url":"https://api.github.com/repos/sys-devel-d/pimp/pulls/22/comments","review_comment_url":"https://api.github.com/repos/sys-devel-d/pimp/pulls/comments{/number}","comments_url":"https://api.github.com/repos/sys-devel-d/pimp/issues/22/comments","statuses_url":"https://api.github.com/repos/sys-devel-d/pimp/statuses/2117bcf72dfa08a2d67ce048e9539099d08527e2","head":{"label":"sys-devel-d:PIMP-56-edit-events","ref":"PIMP-56-edit-events","sha":"2117bcf72dfa08a2d67ce048e9539099d08527e2","user":{"login":"sys-devel-d","id":22912978,"avatar_url":"https://avatars.githubusercontent.com/u/22912978?v=3","gravatar_id":"","url":"https://api.github.com/users/sys-devel-d","html_url":"https://github.com/sys-devel-d","followers_url":"https://api.github.com/users/sys-devel-d/followers","following_url":"https://api.github.com/users/sys-devel-d/following{/other_user}","gists_url":"https://api.github.com/users/sys-devel-d/gists{/gist_id}","starred_url":"https://api.github.com/users/sys-devel-d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sys-devel-d/subscriptions","organizations_url":"https://api.github.com/users/sys-devel-d/orgs","repos_url":"https://api.github.com/users/sys-devel-d/repos","events_url":"https://api.github.com/users/sys-devel-d/events{/privacy}","received_events_url":"https://api.github.com/users/sys-devel-d/received_events","type":"Organization","site_admin":false},"repo":{"id":71252317,"name":"pimp","full_name":"sys-devel-d/pimp","owner":{"login":"sys-devel-d","id":22912978,"avatar_url":"https://avatars.githubusercontent.com/u/22912978?v=3","gravatar_id":"","url":"https://api.github.com/users/sys-devel-d","html_url":"https://github.com/sys-devel-d","followers_url":"https://api.github.com/users/sys-devel-d/followers","following_url":"https://api.github.com/users/sys-devel-d/following{/other_user}","gists_url":"https://api.github.com/users/sys-devel-d/gists{/gist_id}","starred_url":"https://api.github.com/users/sys-devel-d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sys-devel-d/subscriptions","organizations_url":"https://api.github.com/users/sys-devel-d/orgs","repos_url":"https://api.github.com/users/sys-devel-d/repos","events_url":"https://api.github.com/users/sys-devel-d/events{/privacy}","received_events_url":"https://api.github.com/users/sys-devel-d/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sys-devel-d/pimp","description":"Pim Plus","fork":false,"url":"https://api.github.com/repos/sys-devel-d/pimp","forks_url":"https://api.github.com/repos/sys-devel-d/pimp/forks","keys_url":"https://api.github.com/repos/sys-devel-d/pimp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sys-devel-d/pimp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sys-devel-d/pimp/teams","hooks_url":"https://api.github.com/repos/sys-devel-d/pimp/hooks","issue_events_url":"https://api.github.com/repos/sys-devel-d/pimp/issues/events{/number}","events_url":"https://api.github.com/repos/sys-devel-d/pimp/events","assignees_url":"https://api.github.com/repos/sys-devel-d/pimp/assignees{/user}","branches_url":"https://api.github.com/repos/sys-devel-d/pimp/branches{/branch}","tags_url":"https://api.github.com/repos/sys-devel-d/pimp/tags","blobs_url":"https://api.github.com/repos/sys-devel-d/pimp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sys-devel-d/pimp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sys-devel-d/pimp/git/refs{/sha}","trees_url":"https://api.github.com/repos/sys-devel-d/pimp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sys-devel-d/pimp/statuses/{sha}","languages_url":"https://api.github.com/repos/sys-devel-d/pimp/languages","stargazers_url":"https://api.github.com/repos/sys-devel-d/pimp/stargazers","contributors_url":"https://api.github.com/repos/sys-devel-d/pimp/contributors","subscribers_url":"https://api.github.com/repos/sys-devel-d/pimp/subscribers","subscription_url":"https://api.github.com/repos/sys-devel-d/pimp/subscription","commits_url":"https://api.github.com/repos/sys-devel-d/pimp/commits{/sha}","git_commits_url":"https://api.github.com/repos/sys-devel-d/pimp/git/commits{/sha}","comments_url":"https://api.github.com/repos/sys-devel-d/pimp/comments{/number}","issue_comment_url":"https://api.github.com/repos/sys-devel-d/pimp/issues/comments{/number}","contents_url":"https://api.github.com/repos/sys-devel-d/pimp/contents/{+path}","compare_url":"https://api.github.com/repos/sys-devel-d/pimp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sys-devel-d/pimp/merges","archive_url":"https://api.github.com/repos/sys-devel-d/pimp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sys-devel-d/pimp/downloads","issues_url":"https://api.github.com/repos/sys-devel-d/pimp/issues{/number}","pulls_url":"https://api.github.com/repos/sys-devel-d/pimp/pulls{/number}","milestones_url":"https://api.github.com/repos/sys-devel-d/pimp/milestones{/number}","notifications_url":"https://api.github.com/repos/sys-devel-d/pimp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sys-devel-d/pimp/labels{/name}","releases_url":"https://api.github.com/repos/sys-devel-d/pimp/releases{/id}","deployments_url":"https://api.github.com/repos/sys-devel-d/pimp/deployments","created_at":"2016-10-18T13:41:11Z","updated_at":"2016-11-04T20:53:21Z","pushed_at":"2016-12-05T20:51:42Z","git_url":"git://github.com/sys-devel-d/pimp.git","ssh_url":"git@github.com:sys-devel-d/pimp.git","clone_url":"https://github.com/sys-devel-d/pimp.git","svn_url":"https://github.com/sys-devel-d/pimp","homepage":null,"size":164,"stargazers_count":2,"watchers_count":2,"language":"Java","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":"sys-devel-d:master","ref":"master","sha":"74699dc14f39469a96a5bc72efad00452d475397","user":{"login":"sys-devel-d","id":22912978,"avatar_url":"https://avatars.githubusercontent.com/u/22912978?v=3","gravatar_id":"","url":"https://api.github.com/users/sys-devel-d","html_url":"https://github.com/sys-devel-d","followers_url":"https://api.github.com/users/sys-devel-d/followers","following_url":"https://api.github.com/users/sys-devel-d/following{/other_user}","gists_url":"https://api.github.com/users/sys-devel-d/gists{/gist_id}","starred_url":"https://api.github.com/users/sys-devel-d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sys-devel-d/subscriptions","organizations_url":"https://api.github.com/users/sys-devel-d/orgs","repos_url":"https://api.github.com/users/sys-devel-d/repos","events_url":"https://api.github.com/users/sys-devel-d/events{/privacy}","received_events_url":"https://api.github.com/users/sys-devel-d/received_events","type":"Organization","site_admin":false},"repo":{"id":71252317,"name":"pimp","full_name":"sys-devel-d/pimp","owner":{"login":"sys-devel-d","id":22912978,"avatar_url":"https://avatars.githubusercontent.com/u/22912978?v=3","gravatar_id":"","url":"https://api.github.com/users/sys-devel-d","html_url":"https://github.com/sys-devel-d","followers_url":"https://api.github.com/users/sys-devel-d/followers","following_url":"https://api.github.com/users/sys-devel-d/following{/other_user}","gists_url":"https://api.github.com/users/sys-devel-d/gists{/gist_id}","starred_url":"https://api.github.com/users/sys-devel-d/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sys-devel-d/subscriptions","organizations_url":"https://api.github.com/users/sys-devel-d/orgs","repos_url":"https://api.github.com/users/sys-devel-d/repos","events_url":"https://api.github.com/users/sys-devel-d/events{/privacy}","received_events_url":"https://api.github.com/users/sys-devel-d/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/sys-devel-d/pimp","description":"Pim Plus","fork":false,"url":"https://api.github.com/repos/sys-devel-d/pimp","forks_url":"https://api.github.com/repos/sys-devel-d/pimp/forks","keys_url":"https://api.github.com/repos/sys-devel-d/pimp/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sys-devel-d/pimp/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sys-devel-d/pimp/teams","hooks_url":"https://api.github.com/repos/sys-devel-d/pimp/hooks","issue_events_url":"https://api.github.com/repos/sys-devel-d/pimp/issues/events{/number}","events_url":"https://api.github.com/repos/sys-devel-d/pimp/events","assignees_url":"https://api.github.com/repos/sys-devel-d/pimp/assignees{/user}","branches_url":"https://api.github.com/repos/sys-devel-d/pimp/branches{/branch}","tags_url":"https://api.github.com/repos/sys-devel-d/pimp/tags","blobs_url":"https://api.github.com/repos/sys-devel-d/pimp/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sys-devel-d/pimp/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sys-devel-d/pimp/git/refs{/sha}","trees_url":"https://api.github.com/repos/sys-devel-d/pimp/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sys-devel-d/pimp/statuses/{sha}","languages_url":"https://api.github.com/repos/sys-devel-d/pimp/languages","stargazers_url":"https://api.github.com/repos/sys-devel-d/pimp/stargazers","contributors_url":"https://api.github.com/repos/sys-devel-d/pimp/contributors","subscribers_url":"https://api.github.com/repos/sys-devel-d/pimp/subscribers","subscription_url":"https://api.github.com/repos/sys-devel-d/pimp/subscription","commits_url":"https://api.github.com/repos/sys-devel-d/pimp/commits{/sha}","git_commits_url":"https://api.github.com/repos/sys-devel-d/pimp/git/commits{/sha}","comments_url":"https://api.github.com/repos/sys-devel-d/pimp/comments{/number}","issue_comment_url":"https://api.github.com/repos/sys-devel-d/pimp/issues/comments{/number}","contents_url":"https://api.github.com/repos/sys-devel-d/pimp/contents/{+path}","compare_url":"https://api.github.com/repos/sys-devel-d/pimp/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sys-devel-d/pimp/merges","archive_url":"https://api.github.com/repos/sys-devel-d/pimp/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sys-devel-d/pimp/downloads","issues_url":"https://api.github.com/repos/sys-devel-d/pimp/issues{/number}","pulls_url":"https://api.github.com/repos/sys-devel-d/pimp/pulls{/number}","milestones_url":"https://api.github.com/repos/sys-devel-d/pimp/milestones{/number}","notifications_url":"https://api.github.com/repos/sys-devel-d/pimp/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sys-devel-d/pimp/labels{/name}","releases_url":"https://api.github.com/repos/sys-devel-d/pimp/releases{/id}","deployments_url":"https://api.github.com/repos/sys-devel-d/pimp/deployments","created_at":"2016-10-18T13:41:11Z","updated_at":"2016-11-04T20:53:21Z","pushed_at":"2016-12-05T20:51:42Z","git_url":"git://github.com/sys-devel-d/pimp.git","ssh_url":"git@github.com:sys-devel-d/pimp.git","clone_url":"https://github.com/sys-devel-d/pimp.git","svn_url":"https://github.com/sys-devel-d/pimp","homepage":null,"size":164,"stargazers_count":2,"watchers_count":2,"language":"Java","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/sys-devel-d/pimp/pulls/22"},"html":{"href":"https://github.com/sys-devel-d/pimp/pull/22"},"issue":{"href":"https://api.github.com/repos/sys-devel-d/pimp/issues/22"},"comments":{"href":"https://api.github.com/repos/sys-devel-d/pimp/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/sys-devel-d/pimp/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/sys-devel-d/pimp/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/sys-devel-d/pimp/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/sys-devel-d/pimp/statuses/2117bcf72dfa08a2d67ce048e9539099d08527e2"}}}}
{"actor":{"display_login":"haffla"}}