{"action":"created","comment":{"url":"https://api.github.com/repos/opf/openproject/pulls/comments/24976090","id":24976090,"diff_hunk":"@@ -0,0 +1,223 @@\n+#-- encoding: UTF-8\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+module API\n+  module V3\n+    module Utilities\n+      class CustomFieldInjector\n+        TYPE_MAP = {\n+          'string' => 'String',\n+          'text' => 'Formattable',\n+          'int' => 'Integer',\n+          'float' => 'Float',\n+          'date' => 'Date',\n+          'bool' => 'Boolean',\n+          'user' => 'User',\n+          'version' => 'Version',\n+          'list' => 'StringObject'\n+        }\n+\n+        LINK_FORMATS = ['list', 'user', 'version']\n+\n+        PATH_METHOD_MAP = {\n+          'user' => :user,\n+          'version' => :version,\n+          'list' => :string_object\n+        }\n+\n+        NAMESPACE_MAP = {\n+          'user' => 'users',\n+          'version' => 'versions',\n+          'list' => 'string_objects'\n+        }\n+\n+        class << self\n+          def linked_field?(custom_field)\n+            LINK_FORMATS.include?(custom_field.field_format)\n+          end\n+\n+          def property_field?(custom_field)\n+            !linked_field?(custom_field)\n+          end\n+        end\n+\n+        def initialize(representer_class)\n+          @class = representer_class\n+        end\n+\n+        # N.B. accepting a wp_schema here is not too great, but seems like the best way\n+        # to obtain available versions and users for WP custom fields\n+        def inject_schema(custom_field, wp_schema: nil)\n+          case custom_field.field_format\n+          when 'version'\n+            inject_version_schema(custom_field, wp_schema)\n+          when 'user'\n+            inject_user_schema(custom_field, wp_schema)\n+          when 'list'\n+            inject_list_schema(custom_field)\n+          else\n+            inject_basic_schema(custom_field)\n+          end\n+        end\n+\n+        def inject_value(custom_field)\n+          case custom_field.field_format\n+          when *LINK_FORMATS\n+            inject_link_value(custom_field)\n+          else\n+            inject_property_value(custom_field)\n+          end\n+        end\n+\n+        def inject_patchable_link_value(custom_field)","path":"lib/api/v3/utilities/custom_field_injector.rb","position":98,"original_position":98,"commit_id":"2f057f2f3d7cb11bc55dd6472f0bb8668e8640e7","original_commit_id":"2f057f2f3d7cb11bc55dd6472f0bb8668e8640e7","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":"Assignment Branch Condition size for inject_patchable_link_value is too high. [29.56/15]<br>Perceived complexity for inject_patchable_link_value is too high. [9/7]","created_at":"2015-02-19T09:53:36Z","updated_at":"2015-02-19T09:53:36Z","html_url":"https://github.com/opf/openproject/pull/2550#discussion_r24976090","pull_request_url":"https://api.github.com/repos/opf/openproject/pulls/2550","_links":{"self":{"href":"https://api.github.com/repos/opf/openproject/pulls/comments/24976090"},"html":{"href":"https://github.com/opf/openproject/pull/2550#discussion_r24976090"},"pull_request":{"href":"https://api.github.com/repos/opf/openproject/pulls/2550"}}},"pull_request":{"url":"https://api.github.com/repos/opf/openproject/pulls/2550","id":29267371,"html_url":"https://github.com/opf/openproject/pull/2550","diff_url":"https://github.com/opf/openproject/pull/2550.diff","patch_url":"https://github.com/opf/openproject/pull/2550.patch","issue_url":"https://api.github.com/repos/opf/openproject/issues/2550","number":2550,"state":"open","locked":false,"title":"[API] Change representation of custom fields","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 packages\r\n\r\n* https://community.openproject.org/work_packages/18296\r\n* https://community.openproject.org/work_packages/18295\r\n* https://community.openproject.org/work_packages/18294\r\n* https://community.openproject.org/work_packages/18293\r\n* https://community.openproject.org/work_packages/18292\r\n* https://community.openproject.org/work_packages/18291\r\n* https://community.openproject.org/work_packages/18290\r\n* https://community.openproject.org/work_packages/18288\r\n\r\n\r\n## Progress\r\n\r\n* [x] schema for basic custom fields\r\n* [x] schema for linked custom fields\r\n* [x] schema for list custom fields\r\n* [x] basic custom fields in WP representer\r\n* [x] linked custom fields in WP representer\r\n* [x] list custom fields in WP representer\r\n* [x] patchable basic custom fields\r\n* [x] patchable linked custom fields\r\n* [x] patchable list custom fields\r\n* [ ] render text custom fields as formattables (forced to `plain`)\r\n* [ ] full specs for `CustomFieldInjector`\r\n* [ ] find another solution than overwriting new in affected representers\r\n* [ ] clean up messy bits and pieces\r\n* [ ] validation of allowed values","created_at":"2015-02-13T14:18:26Z","updated_at":"2015-02-19T09:53:37Z","closed_at":null,"merged_at":null,"merge_commit_sha":"09117e07151d3a3b8d41ea67779ee09c83ceafff","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/opf/openproject/pulls/2550/commits","review_comments_url":"https://api.github.com/repos/opf/openproject/pulls/2550/comments","review_comment_url":"https://api.github.com/repos/opf/openproject/pulls/comments/{number}","comments_url":"https://api.github.com/repos/opf/openproject/issues/2550/comments","statuses_url":"https://api.github.com/repos/opf/openproject/statuses/2f057f2f3d7cb11bc55dd6472f0bb8668e8640e7","head":{"label":"feature/api_custom_fields_in_schema","ref":"feature/api_custom_fields_in_schema","sha":"2f057f2f3d7cb11bc55dd6472f0bb8668e8640e7","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-02-18T17:08:34Z","pushed_at":"2015-02-19T09:53:28Z","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":167410,"stargazers_count":511,"watchers_count":511,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":224,"mirror_url":null,"open_issues_count":80,"forks":224,"open_issues":80,"watchers":511,"default_branch":"dev"}},"base":{"label":"dev","ref":"dev","sha":"c3fe4e55038578ac48143e7338383f4312f89c41","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-02-18T17:08:34Z","pushed_at":"2015-02-19T09:53:28Z","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":167410,"stargazers_count":511,"watchers_count":511,"language":"Ruby","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":224,"mirror_url":null,"open_issues_count":80,"forks":224,"open_issues":80,"watchers":511,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/opf/openproject/pulls/2550"},"html":{"href":"https://github.com/opf/openproject/pull/2550"},"issue":{"href":"https://api.github.com/repos/opf/openproject/issues/2550"},"comments":{"href":"https://api.github.com/repos/opf/openproject/issues/2550/comments"},"review_comments":{"href":"https://api.github.com/repos/opf/openproject/pulls/2550/comments"},"review_comment":{"href":"https://api.github.com/repos/opf/openproject/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/opf/openproject/pulls/2550/commits"},"statuses":{"href":"https://api.github.com/repos/opf/openproject/statuses/2f057f2f3d7cb11bc55dd6472f0bb8668e8640e7"}}}}