{"action":"created","comment":{"url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments/206540547","pull_request_review_id":141965225,"id":206540547,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIwNjU0MDU0Nw==","diff_hunk":"@@ -0,0 +1,87 @@\n+<?php\n+\n+declare(strict_types=1);\n+\n+namespace Pim\\Bundle\\DataGridBundle\\Controller;\n+\n+use Akeneo\\Pim\\Structure\\Component\\Repository\\AttributeRepositoryInterface;\n+use Oro\\Bundle\\DataGridBundle\\Datagrid\\Common\\DatagridConfiguration;\n+use Oro\\Bundle\\DataGridBundle\\Datagrid\\Common\\MetadataIterableObject;\n+use Oro\\Bundle\\FilterBundle\\Grid\\Extension\\Configuration as FilterConfiguration;\n+use Pim\\Bundle\\DataGridBundle\\Datagrid\\Configuration\\ConfiguratorInterface;\n+use Pim\\Bundle\\DataGridBundle\\Datagrid\\Configuration\\Product\\FiltersConfigurator;\n+use Pim\\Bundle\\DataGridBundle\\Extension\\Filter\\FilterExtension;\n+use Symfony\\Component\\HttpFoundation\\JsonResponse;\n+use Symfony\\Component\\HttpFoundation\\Request;\n+\n+class ProductGridController\n+{\n+    /** @var AttributeRepositoryInterface */\n+    private $attributeRepository;\n+\n+    /** @var FiltersConfigurator */\n+    private $filtersConfigurator;\n+\n+    /** @var FilterExtension */\n+    private $filterExtension;\n+\n+    /** @var int */\n+    private $attributesPerPage;\n+\n+    /**\n+     * @param AttributeRepositoryInterface $attributeRepository\n+     * @param FiltersConfigurator          $filtersConfigurator\n+     * @param FilterExtension              $filterExtension\n+     * @param int                          $attributesPerPage\n+     */\n+    public function __construct(\n+        AttributeRepositoryInterface $attributeRepository,\n+        FiltersConfigurator $filtersConfigurator,\n+        FilterExtension $filterExtension,\n+        int $attributesPerPage\n+    ) {\n+        $this->attributeRepository = $attributeRepository;\n+        $this->filtersConfigurator = $filtersConfigurator;\n+        $this->filterExtension = $filterExtension;\n+        $this->attributesPerPage = $attributesPerPage;\n+    }\n+\n+    /**\n+     * Get the list of attributes used as filters in the product grid.\n+     * For performance reasons, the number of attributes per response is limited.\n+     *\n+     * @param Request $request\n+     *\n+     * @return JsonResponse\n+     */\n+    public function getAttributesAsFiltersAction(Request $request): JsonResponse\n+    {\n+        $offset = (int) $request->get('offset', 0);\n+        $locale = $request->get('locale', 'en_US'); // TODO: get user default locale\n+\n+        $attributes = $this->attributeRepository->getAttributesUsableAsFiltersInProductGrid($locale, $this->attributesPerPage, $offset);\n+\n+        // Format the list of attributes to be able to use it in FilterConfiguration and FilterExtension\n+        foreach ($attributes as $index => $attribute) {\n+            $attribute['group'] = $attribute['groupLabel'];\n+            $attribute['order'] = $attribute['sortOrder'];\n+\n+            $attributes[$attribute['code']] = $attribute;\n+            unset($attributes[$index]);","path":"src/Pim/Bundle/DataGridBundle/Controller/ProductGridController.php","position":70,"original_position":70,"commit_id":"79b1b81a350e63d92d6175ef1373e545e8576b5a","original_commit_id":"79b1b81a350e63d92d6175ef1373e545e8576b5a","user":{"login":"ahocquard","id":1942439,"node_id":"MDQ6VXNlcjE5NDI0Mzk=","avatar_url":"https://avatars0.githubusercontent.com/u/1942439?v=4","gravatar_id":"","url":"https://api.github.com/users/ahocquard","html_url":"https://github.com/ahocquard","followers_url":"https://api.github.com/users/ahocquard/followers","following_url":"https://api.github.com/users/ahocquard/following{/other_user}","gists_url":"https://api.github.com/users/ahocquard/gists{/gist_id}","starred_url":"https://api.github.com/users/ahocquard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ahocquard/subscriptions","organizations_url":"https://api.github.com/users/ahocquard/orgs","repos_url":"https://api.github.com/users/ahocquard/repos","events_url":"https://api.github.com/users/ahocquard/events{/privacy}","received_events_url":"https://api.github.com/users/ahocquard/received_events","type":"User","site_admin":false},"body":"create a new array? I don't like to modify the array where that you iterate.","created_at":"2018-07-31T14:03:12Z","updated_at":"2018-07-31T14:04:16Z","html_url":"https://github.com/akeneo/pim-community-dev/pull/8590#discussion_r206540547","pull_request_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/8590","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments/206540547"},"html":{"href":"https://github.com/akeneo/pim-community-dev/pull/8590#discussion_r206540547"},"pull_request":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/8590"}}},"pull_request":{"url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/8590","id":205110925,"node_id":"MDExOlB1bGxSZXF1ZXN0MjA1MTEwOTI1","html_url":"https://github.com/akeneo/pim-community-dev/pull/8590","diff_url":"https://github.com/akeneo/pim-community-dev/pull/8590.diff","patch_url":"https://github.com/akeneo/pim-community-dev/pull/8590.patch","issue_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/8590","number":8590,"state":"open","locked":false,"title":"[POC] Load the product grid attributes from dedicated endpoints","user":{"login":"LaurentPetard","id":26378046,"node_id":"MDQ6VXNlcjI2Mzc4MDQ2","avatar_url":"https://avatars1.githubusercontent.com/u/26378046?v=4","gravatar_id":"","url":"https://api.github.com/users/LaurentPetard","html_url":"https://github.com/LaurentPetard","followers_url":"https://api.github.com/users/LaurentPetard/followers","following_url":"https://api.github.com/users/LaurentPetard/following{/other_user}","gists_url":"https://api.github.com/users/LaurentPetard/gists{/gist_id}","starred_url":"https://api.github.com/users/LaurentPetard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/LaurentPetard/subscriptions","organizations_url":"https://api.github.com/users/LaurentPetard/orgs","repos_url":"https://api.github.com/users/LaurentPetard/repos","events_url":"https://api.github.com/users/LaurentPetard/events{/privacy}","received_events_url":"https://api.github.com/users/LaurentPetard/received_events","type":"User","site_admin":false},"body":"Currently all the attributes \"usable in grid\" are loaded in the metadata of the product grid. This causes performance issues when there's a huge number of attributes in the catalog.\r\n\r\nThe goal of this POC is to load theses attributes in dedicated endpoints and with paginated responses. ","created_at":"2018-07-31T13:22:58Z","updated_at":"2018-07-31T14:04:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"d1f8942237afdc98941a9a0b92bfb735d587d770","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/8590/commits","review_comments_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/8590/comments","review_comment_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments{/number}","comments_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/8590/comments","statuses_url":"https://api.github.com/repos/akeneo/pim-community-dev/statuses/79b1b81a350e63d92d6175ef1373e545e8576b5a","head":{"label":"akeneo:poc-pim-7527","ref":"poc-pim-7527","sha":"79b1b81a350e63d92d6175ef1373e545e8576b5a","user":{"login":"akeneo","id":2510186,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTAxODY=","avatar_url":"https://avatars0.githubusercontent.com/u/2510186?v=4","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"repo":{"id":5367323,"node_id":"MDEwOlJlcG9zaXRvcnk1MzY3MzIz","name":"pim-community-dev","full_name":"akeneo/pim-community-dev","owner":{"login":"akeneo","id":2510186,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTAxODY=","avatar_url":"https://avatars0.githubusercontent.com/u/2510186?v=4","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akeneo/pim-community-dev","description":"[Community Development Repository] The open source Product Information Management (PIM)","fork":false,"url":"https://api.github.com/repos/akeneo/pim-community-dev","forks_url":"https://api.github.com/repos/akeneo/pim-community-dev/forks","keys_url":"https://api.github.com/repos/akeneo/pim-community-dev/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akeneo/pim-community-dev/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akeneo/pim-community-dev/teams","hooks_url":"https://api.github.com/repos/akeneo/pim-community-dev/hooks","issue_events_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/events{/number}","events_url":"https://api.github.com/repos/akeneo/pim-community-dev/events","assignees_url":"https://api.github.com/repos/akeneo/pim-community-dev/assignees{/user}","branches_url":"https://api.github.com/repos/akeneo/pim-community-dev/branches{/branch}","tags_url":"https://api.github.com/repos/akeneo/pim-community-dev/tags","blobs_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/refs{/sha}","trees_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akeneo/pim-community-dev/statuses/{sha}","languages_url":"https://api.github.com/repos/akeneo/pim-community-dev/languages","stargazers_url":"https://api.github.com/repos/akeneo/pim-community-dev/stargazers","contributors_url":"https://api.github.com/repos/akeneo/pim-community-dev/contributors","subscribers_url":"https://api.github.com/repos/akeneo/pim-community-dev/subscribers","subscription_url":"https://api.github.com/repos/akeneo/pim-community-dev/subscription","commits_url":"https://api.github.com/repos/akeneo/pim-community-dev/commits{/sha}","git_commits_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/commits{/sha}","comments_url":"https://api.github.com/repos/akeneo/pim-community-dev/comments{/number}","issue_comment_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/comments{/number}","contents_url":"https://api.github.com/repos/akeneo/pim-community-dev/contents/{+path}","compare_url":"https://api.github.com/repos/akeneo/pim-community-dev/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akeneo/pim-community-dev/merges","archive_url":"https://api.github.com/repos/akeneo/pim-community-dev/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akeneo/pim-community-dev/downloads","issues_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues{/number}","pulls_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls{/number}","milestones_url":"https://api.github.com/repos/akeneo/pim-community-dev/milestones{/number}","notifications_url":"https://api.github.com/repos/akeneo/pim-community-dev/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akeneo/pim-community-dev/labels{/name}","releases_url":"https://api.github.com/repos/akeneo/pim-community-dev/releases{/id}","deployments_url":"https://api.github.com/repos/akeneo/pim-community-dev/deployments","created_at":"2012-08-10T09:27:26Z","updated_at":"2018-07-31T10:03:33Z","pushed_at":"2018-07-31T14:01:40Z","git_url":"git://github.com/akeneo/pim-community-dev.git","ssh_url":"git@github.com:akeneo/pim-community-dev.git","clone_url":"https://github.com/akeneo/pim-community-dev.git","svn_url":"https://github.com/akeneo/pim-community-dev","homepage":"http://www.akeneo.com","size":144965,"stargazers_count":535,"watchers_count":535,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":324,"mirror_url":null,"archived":false,"open_issues_count":268,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":324,"open_issues":268,"watchers":535,"default_branch":"master"}},"base":{"label":"akeneo:master","ref":"master","sha":"e21b2b1819c3da24fd6fdbb16494a37d59d30fc2","user":{"login":"akeneo","id":2510186,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTAxODY=","avatar_url":"https://avatars0.githubusercontent.com/u/2510186?v=4","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"repo":{"id":5367323,"node_id":"MDEwOlJlcG9zaXRvcnk1MzY3MzIz","name":"pim-community-dev","full_name":"akeneo/pim-community-dev","owner":{"login":"akeneo","id":2510186,"node_id":"MDEyOk9yZ2FuaXphdGlvbjI1MTAxODY=","avatar_url":"https://avatars0.githubusercontent.com/u/2510186?v=4","gravatar_id":"","url":"https://api.github.com/users/akeneo","html_url":"https://github.com/akeneo","followers_url":"https://api.github.com/users/akeneo/followers","following_url":"https://api.github.com/users/akeneo/following{/other_user}","gists_url":"https://api.github.com/users/akeneo/gists{/gist_id}","starred_url":"https://api.github.com/users/akeneo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/akeneo/subscriptions","organizations_url":"https://api.github.com/users/akeneo/orgs","repos_url":"https://api.github.com/users/akeneo/repos","events_url":"https://api.github.com/users/akeneo/events{/privacy}","received_events_url":"https://api.github.com/users/akeneo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/akeneo/pim-community-dev","description":"[Community Development Repository] The open source Product Information Management (PIM)","fork":false,"url":"https://api.github.com/repos/akeneo/pim-community-dev","forks_url":"https://api.github.com/repos/akeneo/pim-community-dev/forks","keys_url":"https://api.github.com/repos/akeneo/pim-community-dev/keys{/key_id}","collaborators_url":"https://api.github.com/repos/akeneo/pim-community-dev/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/akeneo/pim-community-dev/teams","hooks_url":"https://api.github.com/repos/akeneo/pim-community-dev/hooks","issue_events_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/events{/number}","events_url":"https://api.github.com/repos/akeneo/pim-community-dev/events","assignees_url":"https://api.github.com/repos/akeneo/pim-community-dev/assignees{/user}","branches_url":"https://api.github.com/repos/akeneo/pim-community-dev/branches{/branch}","tags_url":"https://api.github.com/repos/akeneo/pim-community-dev/tags","blobs_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/refs{/sha}","trees_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/trees{/sha}","statuses_url":"https://api.github.com/repos/akeneo/pim-community-dev/statuses/{sha}","languages_url":"https://api.github.com/repos/akeneo/pim-community-dev/languages","stargazers_url":"https://api.github.com/repos/akeneo/pim-community-dev/stargazers","contributors_url":"https://api.github.com/repos/akeneo/pim-community-dev/contributors","subscribers_url":"https://api.github.com/repos/akeneo/pim-community-dev/subscribers","subscription_url":"https://api.github.com/repos/akeneo/pim-community-dev/subscription","commits_url":"https://api.github.com/repos/akeneo/pim-community-dev/commits{/sha}","git_commits_url":"https://api.github.com/repos/akeneo/pim-community-dev/git/commits{/sha}","comments_url":"https://api.github.com/repos/akeneo/pim-community-dev/comments{/number}","issue_comment_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues/comments{/number}","contents_url":"https://api.github.com/repos/akeneo/pim-community-dev/contents/{+path}","compare_url":"https://api.github.com/repos/akeneo/pim-community-dev/compare/{base}...{head}","merges_url":"https://api.github.com/repos/akeneo/pim-community-dev/merges","archive_url":"https://api.github.com/repos/akeneo/pim-community-dev/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/akeneo/pim-community-dev/downloads","issues_url":"https://api.github.com/repos/akeneo/pim-community-dev/issues{/number}","pulls_url":"https://api.github.com/repos/akeneo/pim-community-dev/pulls{/number}","milestones_url":"https://api.github.com/repos/akeneo/pim-community-dev/milestones{/number}","notifications_url":"https://api.github.com/repos/akeneo/pim-community-dev/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/akeneo/pim-community-dev/labels{/name}","releases_url":"https://api.github.com/repos/akeneo/pim-community-dev/releases{/id}","deployments_url":"https://api.github.com/repos/akeneo/pim-community-dev/deployments","created_at":"2012-08-10T09:27:26Z","updated_at":"2018-07-31T10:03:33Z","pushed_at":"2018-07-31T14:01:40Z","git_url":"git://github.com/akeneo/pim-community-dev.git","ssh_url":"git@github.com:akeneo/pim-community-dev.git","clone_url":"https://github.com/akeneo/pim-community-dev.git","svn_url":"https://github.com/akeneo/pim-community-dev","homepage":"http://www.akeneo.com","size":144965,"stargazers_count":535,"watchers_count":535,"language":"PHP","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":324,"mirror_url":null,"archived":false,"open_issues_count":268,"license":{"key":"other","name":"Other","spdx_id":null,"url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":324,"open_issues":268,"watchers":535,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/8590"},"html":{"href":"https://github.com/akeneo/pim-community-dev/pull/8590"},"issue":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/issues/8590"},"comments":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/issues/8590/comments"},"review_comments":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/8590/comments"},"review_comment":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/pulls/8590/commits"},"statuses":{"href":"https://api.github.com/repos/akeneo/pim-community-dev/statuses/79b1b81a350e63d92d6175ef1373e545e8576b5a"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"ahocquard"}}