{"action":"created","comment":{"url":"https://api.github.com/repos/opf/openproject/pulls/comments/35454791","id":35454791,"diff_hunk":"@@ -0,0 +1,78 @@\n+#-- copyright\n+# OpenProject is a project management system.\n+# Copyright (C) 2012-2015 the OpenProject Foundation (OPF)\n+#\n+# This program is free software; you can redistribute it and/or\n+# modify it under the terms of the GNU General Public License version 3.\n+#\n+# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:\n+# Copyright (C) 2006-2013 Jean-Philippe Lang\n+# Copyright (C) 2010-2013 the ChiliProject Team\n+#\n+# This program is free software; you can redistribute it and/or\n+# modify it under the terms of the GNU General Public License\n+# as published by the Free Software Foundation; either version 2\n+# of the License, or (at your option) any later version.\n+#\n+# This program is distributed in the hope that it will be useful,\n+# but WITHOUT ANY WARRANTY; without even the implied warranty of\n+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n+# GNU General Public License for more details.\n+#\n+# You should have received a copy of the GNU General Public License\n+# along with this program; if not, write to the Free Software\n+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n+#\n+# See doc/COPYRIGHT.rdoc for more details.\n+#++\n+\n+#-- encoding: UTF-8\n+module JournalChanges\n+  def get_changes\n+    return {} if data.nil?\n+    return @changes if @changes\n+\n+    @changes = HashWithIndifferentAccess.new\n+\n+    if predecessor.nil?\n+      @changes = data.journaled_attributes.select { |_, v| !v.nil? }\n+                   .inject({}) { |h, (k, v)| h[k] = [nil, v]; h }\n+    else\n+      normalized_data = JournalManager.normalize_newlines(data.journaled_attributes)\n+      normalized_predecessor_data = JournalManager.normalize_newlines(predecessor.data.journaled_attributes)\n+\n+      normalized_data.select do |k, v|\n+        # we dont record changes for changes from nil to empty strings and vice versa\n+        pred = normalized_predecessor_data[k]\n+        v != pred && (v.present? || pred.present?)\n+      end.each do |k, v|\n+        @changes[k] = [normalized_predecessor_data[k], v]\n+      end\n+    end\n+\n+    @changes.merge!(get_association_changes predecessor, 'attachable', 'attachments', :attachment_id, :filename)\n+    @changes.merge!(get_association_changes predecessor, 'customizable', 'custom_fields', :custom_field_id, :value)","path":"lib/plugins/acts_as_journalized/lib/journal_changes.rb","position":54,"original_position":54,"commit_id":"af635b78a320c3f24c10d9cb18aa744d77902e9a","original_commit_id":"af635b78a320c3f24c10d9cb18aa744d77902e9a","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":"Line is too long. [115/100]","created_at":"2015-07-24T18:57:46Z","updated_at":"2015-07-24T18:57:46Z","html_url":"https://github.com/opf/openproject/pull/3275#discussion_r35454791","pull_request_url":"https://api.github.com/repos/opf/openproject/pulls/3275","_links":{"self":{"href":"https://api.github.com/repos/opf/openproject/pulls/comments/35454791"},"html":{"href":"https://github.com/opf/openproject/pull/3275#discussion_r35454791"},"pull_request":{"href":"https://api.github.com/repos/opf/openproject/pulls/3275"}}},"pull_request":{"url":"https://api.github.com/repos/opf/openproject/pulls/3275","id":40784534,"html_url":"https://github.com/opf/openproject/pull/3275","diff_url":"https://github.com/opf/openproject/pull/3275.diff","patch_url":"https://github.com/opf/openproject/pull/3275.patch","issue_url":"https://api.github.com/repos/opf/openproject/issues/3275","number":3275,"state":"open","locked":false,"title":"Aggregate journals in APIv3","user":{"login":"NobodysNightmare","id":453584,"avatar_url":"https://avatars.githubusercontent.com/u/453584?v=3","gravatar_id":"","url":"https://api.github.com/users/NobodysNightmare","html_url":"https://github.com/NobodysNightmare","followers_url":"https://api.github.com/users/NobodysNightmare/followers","following_url":"https://api.github.com/users/NobodysNightmare/following{/other_user}","gists_url":"https://api.github.com/users/NobodysNightmare/gists{/gist_id}","starred_url":"https://api.github.com/users/NobodysNightmare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NobodysNightmare/subscriptions","organizations_url":"https://api.github.com/users/NobodysNightmare/orgs","repos_url":"https://api.github.com/users/NobodysNightmare/repos","events_url":"https://api.github.com/users/NobodysNightmare/events{/privacy}","received_events_url":"https://api.github.com/users/NobodysNightmare/received_events","type":"User","site_admin":false},"body":"## OpenProject work package\r\n\r\nhttps://community.openproject.org/work_packages/20688\r\n\r\n## Description\r\n\r\nStarting with this PR the APIv3 activities return their results in an aggregated form.\r\nSome work on the `Journal::AggregatedJournals` was still neccessary.\r\n\r\n**WP legcy form (non-aggregated)**\r\n![non-aggregated](https://cloud.githubusercontent.com/assets/453584/8877643/a1349582-3226-11e5-853b-9e7bc6afe8e3.PNG)\r\n\r\n**inplace view (aggregated)**\r\n![aggregated](https://cloud.githubusercontent.com/assets/453584/8877642/a1343b32-3226-11e5-9a44-7a4558b6253a.PNG)\r\n","created_at":"2015-07-24T15:09:27Z","updated_at":"2015-07-24T18:57:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"857ac01cefe4a3b464025ccd8b6fc491f400c63c","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/opf/openproject/pulls/3275/commits","review_comments_url":"https://api.github.com/repos/opf/openproject/pulls/3275/comments","review_comment_url":"https://api.github.com/repos/opf/openproject/pulls/comments{/number}","comments_url":"https://api.github.com/repos/opf/openproject/issues/3275/comments","statuses_url":"https://api.github.com/repos/opf/openproject/statuses/af635b78a320c3f24c10d9cb18aa744d77902e9a","head":{"label":"NobodysNightmare:feature/aggregated_api_journals","ref":"feature/aggregated_api_journals","sha":"af635b78a320c3f24c10d9cb18aa744d77902e9a","user":{"login":"NobodysNightmare","id":453584,"avatar_url":"https://avatars.githubusercontent.com/u/453584?v=3","gravatar_id":"","url":"https://api.github.com/users/NobodysNightmare","html_url":"https://github.com/NobodysNightmare","followers_url":"https://api.github.com/users/NobodysNightmare/followers","following_url":"https://api.github.com/users/NobodysNightmare/following{/other_user}","gists_url":"https://api.github.com/users/NobodysNightmare/gists{/gist_id}","starred_url":"https://api.github.com/users/NobodysNightmare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NobodysNightmare/subscriptions","organizations_url":"https://api.github.com/users/NobodysNightmare/orgs","repos_url":"https://api.github.com/users/NobodysNightmare/repos","events_url":"https://api.github.com/users/NobodysNightmare/events{/privacy}","received_events_url":"https://api.github.com/users/NobodysNightmare/received_events","type":"User","site_admin":false},"repo":{"id":31598524,"name":"openproject","full_name":"NobodysNightmare/openproject","owner":{"login":"NobodysNightmare","id":453584,"avatar_url":"https://avatars.githubusercontent.com/u/453584?v=3","gravatar_id":"","url":"https://api.github.com/users/NobodysNightmare","html_url":"https://github.com/NobodysNightmare","followers_url":"https://api.github.com/users/NobodysNightmare/followers","following_url":"https://api.github.com/users/NobodysNightmare/following{/other_user}","gists_url":"https://api.github.com/users/NobodysNightmare/gists{/gist_id}","starred_url":"https://api.github.com/users/NobodysNightmare/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/NobodysNightmare/subscriptions","organizations_url":"https://api.github.com/users/NobodysNightmare/orgs","repos_url":"https://api.github.com/users/NobodysNightmare/repos","events_url":"https://api.github.com/users/NobodysNightmare/events{/privacy}","received_events_url":"https://api.github.com/users/NobodysNightmare/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/NobodysNightmare/openproject","description":"OpenProject is a web-based project management system built on Ruby on Rails","fork":true,"url":"https://api.github.com/repos/NobodysNightmare/openproject","forks_url":"https://api.github.com/repos/NobodysNightmare/openproject/forks","keys_url":"https://api.github.com/repos/NobodysNightmare/openproject/keys{/key_id}","collaborators_url":"https://api.github.com/repos/NobodysNightmare/openproject/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/NobodysNightmare/openproject/teams","hooks_url":"https://api.github.com/repos/NobodysNightmare/openproject/hooks","issue_events_url":"https://api.github.com/repos/NobodysNightmare/openproject/issues/events{/number}","events_url":"https://api.github.com/repos/NobodysNightmare/openproject/events","assignees_url":"https://api.github.com/repos/NobodysNightmare/openproject/assignees{/user}","branches_url":"https://api.github.com/repos/NobodysNightmare/openproject/branches{/branch}","tags_url":"https://api.github.com/repos/NobodysNightmare/openproject/tags","blobs_url":"https://api.github.com/repos/NobodysNightmare/openproject/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/NobodysNightmare/openproject/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/NobodysNightmare/openproject/git/refs{/sha}","trees_url":"https://api.github.com/repos/NobodysNightmare/openproject/git/trees{/sha}","statuses_url":"https://api.github.com/repos/NobodysNightmare/openproject/statuses/{sha}","languages_url":"https://api.github.com/repos/NobodysNightmare/openproject/languages","stargazers_url":"https://api.github.com/repos/NobodysNightmare/openproject/stargazers","contributors_url":"https://api.github.com/repos/NobodysNightmare/openproject/contributors","subscribers_url":"https://api.github.com/repos/NobodysNightmare/openproject/subscribers","subscription_url":"https://api.github.com/repos/NobodysNightmare/openproject/subscription","commits_url":"https://api.github.com/repos/NobodysNightmare/openproject/commits{/sha}","git_commits_url":"https://api.github.com/repos/NobodysNightmare/openproject/git/commits{/sha}","comments_url":"https://api.github.com/repos/NobodysNightmare/openproject/comments{/number}","issue_comment_url":"https://api.github.com/repos/NobodysNightmare/openproject/issues/comments{/number}","contents_url":"https://api.github.com/repos/NobodysNightmare/openproject/contents/{+path}","compare_url":"https://api.github.com/repos/NobodysNightmare/openproject/compare/{base}...{head}","merges_url":"https://api.github.com/repos/NobodysNightmare/openproject/merges","archive_url":"https://api.github.com/repos/NobodysNightmare/openproject/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/NobodysNightmare/openproject/downloads","issues_url":"https://api.github.com/repos/NobodysNightmare/openproject/issues{/number}","pulls_url":"https://api.github.com/repos/NobodysNightmare/openproject/pulls{/number}","milestones_url":"https://api.github.com/repos/NobodysNightmare/openproject/milestones{/number}","notifications_url":"https://api.github.com/repos/NobodysNightmare/openproject/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/NobodysNightmare/openproject/labels{/name}","releases_url":"https://api.github.com/repos/NobodysNightmare/openproject/releases{/id}","created_at":"2015-03-03T13:00:18Z","updated_at":"2015-04-01T12:02:52Z","pushed_at":"2015-07-24T15:05:18Z","git_url":"git://github.com/NobodysNightmare/openproject.git","ssh_url":"git@github.com:NobodysNightmare/openproject.git","clone_url":"https://github.com/NobodysNightmare/openproject.git","svn_url":"https://github.com/NobodysNightmare/openproject","homepage":"https://www.openproject.org","size":65486,"stargazers_count":0,"watchers_count":0,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"dev"}},"base":{"label":"opf:release/4.3","ref":"release/4.3","sha":"542335195cea33f0f5492a1fe448b5ea86790e30","user":{"login":"opf","id":1756674,"avatar_url":"https://avatars.githubusercontent.com/u/1756674?v=3","gravatar_id":"","url":"https://api.github.com/users/opf","html_url":"https://github.com/opf","followers_url":"https://api.github.com/users/opf/followers","following_url":"https://api.github.com/users/opf/following{/other_user}","gists_url":"https://api.github.com/users/opf/gists{/gist_id}","starred_url":"https://api.github.com/users/opf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opf/subscriptions","organizations_url":"https://api.github.com/users/opf/orgs","repos_url":"https://api.github.com/users/opf/repos","events_url":"https://api.github.com/users/opf/events{/privacy}","received_events_url":"https://api.github.com/users/opf/received_events","type":"Organization","site_admin":false},"repo":{"id":6899875,"name":"openproject","full_name":"opf/openproject","owner":{"login":"opf","id":1756674,"avatar_url":"https://avatars.githubusercontent.com/u/1756674?v=3","gravatar_id":"","url":"https://api.github.com/users/opf","html_url":"https://github.com/opf","followers_url":"https://api.github.com/users/opf/followers","following_url":"https://api.github.com/users/opf/following{/other_user}","gists_url":"https://api.github.com/users/opf/gists{/gist_id}","starred_url":"https://api.github.com/users/opf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/opf/subscriptions","organizations_url":"https://api.github.com/users/opf/orgs","repos_url":"https://api.github.com/users/opf/repos","events_url":"https://api.github.com/users/opf/events{/privacy}","received_events_url":"https://api.github.com/users/opf/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/opf/openproject","description":"OpenProject is a web-based project management system built on Ruby on Rails","fork":false,"url":"https://api.github.com/repos/opf/openproject","forks_url":"https://api.github.com/repos/opf/openproject/forks","keys_url":"https://api.github.com/repos/opf/openproject/keys{/key_id}","collaborators_url":"https://api.github.com/repos/opf/openproject/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/opf/openproject/teams","hooks_url":"https://api.github.com/repos/opf/openproject/hooks","issue_events_url":"https://api.github.com/repos/opf/openproject/issues/events{/number}","events_url":"https://api.github.com/repos/opf/openproject/events","assignees_url":"https://api.github.com/repos/opf/openproject/assignees{/user}","branches_url":"https://api.github.com/repos/opf/openproject/branches{/branch}","tags_url":"https://api.github.com/repos/opf/openproject/tags","blobs_url":"https://api.github.com/repos/opf/openproject/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/opf/openproject/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/opf/openproject/git/refs{/sha}","trees_url":"https://api.github.com/repos/opf/openproject/git/trees{/sha}","statuses_url":"https://api.github.com/repos/opf/openproject/statuses/{sha}","languages_url":"https://api.github.com/repos/opf/openproject/languages","stargazers_url":"https://api.github.com/repos/opf/openproject/stargazers","contributors_url":"https://api.github.com/repos/opf/openproject/contributors","subscribers_url":"https://api.github.com/repos/opf/openproject/subscribers","subscription_url":"https://api.github.com/repos/opf/openproject/subscription","commits_url":"https://api.github.com/repos/opf/openproject/commits{/sha}","git_commits_url":"https://api.github.com/repos/opf/openproject/git/commits{/sha}","comments_url":"https://api.github.com/repos/opf/openproject/comments{/number}","issue_comment_url":"https://api.github.com/repos/opf/openproject/issues/comments{/number}","contents_url":"https://api.github.com/repos/opf/openproject/contents/{+path}","compare_url":"https://api.github.com/repos/opf/openproject/compare/{base}...{head}","merges_url":"https://api.github.com/repos/opf/openproject/merges","archive_url":"https://api.github.com/repos/opf/openproject/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/opf/openproject/downloads","issues_url":"https://api.github.com/repos/opf/openproject/issues{/number}","pulls_url":"https://api.github.com/repos/opf/openproject/pulls{/number}","milestones_url":"https://api.github.com/repos/opf/openproject/milestones{/number}","notifications_url":"https://api.github.com/repos/opf/openproject/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/opf/openproject/labels{/name}","releases_url":"https://api.github.com/repos/opf/openproject/releases{/id}","created_at":"2012-11-28T09:59:11Z","updated_at":"2015-07-23T13:56:12Z","pushed_at":"2015-07-24T18:26:02Z","git_url":"git://github.com/opf/openproject.git","ssh_url":"git@github.com:opf/openproject.git","clone_url":"https://github.com/opf/openproject.git","svn_url":"https://github.com/opf/openproject","homepage":"https://www.openproject.org","size":204930,"stargazers_count":685,"watchers_count":685,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":290,"mirror_url":null,"open_issues_count":25,"forks":290,"open_issues":25,"watchers":685,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/opf/openproject/pulls/3275"},"html":{"href":"https://github.com/opf/openproject/pull/3275"},"issue":{"href":"https://api.github.com/repos/opf/openproject/issues/3275"},"comments":{"href":"https://api.github.com/repos/opf/openproject/issues/3275/comments"},"review_comments":{"href":"https://api.github.com/repos/opf/openproject/pulls/3275/comments"},"review_comment":{"href":"https://api.github.com/repos/opf/openproject/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/opf/openproject/pulls/3275/commits"},"statuses":{"href":"https://api.github.com/repos/opf/openproject/statuses/af635b78a320c3f24c10d9cb18aa744d77902e9a"}}}}