{"action":"created","comment":{"url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/comments/135798262","pull_request_review_id":59250381,"id":135798262,"diff_hunk":"@@ -688,22 +690,46 @@ private BoolQueryBuilder createBoolFilter(IssueQuery query) {\n         .addAggregation(AggregationBuilders\n           .filter(projectUuid, boolQuery()\n             .filter(termQuery(IssueIndexDefinition.FIELD_ISSUE_PROJECT_UUID, projectUuid))\n-            .filter(rangeQuery(IssueIndexDefinition.FIELD_ISSUE_FUNC_CREATED_AT).gte(epochMillisToEpochSeconds(from)))\n-          )\n+            .filter(rangeQuery(IssueIndexDefinition.FIELD_ISSUE_FUNC_CREATED_AT).gte(epochMillisToEpochSeconds(from))))\n           .subAggregation(AggregationBuilders.count(projectUuid + \"_count\").field(IssueIndexDefinition.FIELD_ISSUE_KEY))\n-          .subAggregation(AggregationBuilders.max(projectUuid + \"_maxFuncCreatedAt\").field(IssueIndexDefinition.FIELD_ISSUE_FUNC_CREATED_AT))\n-        );\n+          .subAggregation(AggregationBuilders.max(projectUuid + \"_maxFuncCreatedAt\").field(IssueIndexDefinition.FIELD_ISSUE_FUNC_CREATED_AT)));\n     });\n     SearchResponse response = request.get();\n     return response.getAggregations().asList().stream()\n       .map(x -> (InternalFilter) x)\n       .flatMap(projectBucket -> {\n-      long count = ((InternalValueCount) projectBucket.getAggregations().get(projectBucket.getName() + \"_count\")).getValue();\n-      if (count < 1L) {\n-        return Stream.empty();\n-      }\n-      long lastIssueDate = (long) ((InternalMax) projectBucket.getAggregations().get(projectBucket.getName() + \"_maxFuncCreatedAt\")).getValue();\n-      return Stream.of(new ProjectStatistics(projectBucket.getName(), count, lastIssueDate));\n-    }).collect(MoreCollectors.toList(projectUuids.size()));\n+        long count = ((InternalValueCount) projectBucket.getAggregations().get(projectBucket.getName() + \"_count\")).getValue();\n+        if (count < 1L) {\n+          return Stream.empty();\n+        }\n+        long lastIssueDate = (long) ((InternalMax) projectBucket.getAggregations().get(projectBucket.getName() + \"_maxFuncCreatedAt\")).getValue();\n+        return Stream.of(new ProjectStatistics(projectBucket.getName(), count, lastIssueDate));\n+      }).collect(MoreCollectors.toList(projectUuids.size()));\n   }\n+\n+  public List<BranchStatistics> searchBranchStatistics(List<String> branchUuids) {\n+    if (branchUuids.isEmpty()) {\n+      return Collections.emptyList();\n+    }\n+\n+    SearchRequestBuilder request = client.prepareSearch(IssueIndexDefinition.INDEX_TYPE_ISSUE)\n+      .setQuery(\n+        boolQuery()\n+          .must(termsQuery(IssueIndexDefinition.FIELD_ISSUE_BRANCH_UUID, branchUuids))\n+          .must(termQuery(IssueIndexDefinition.FIELD_ISSUE_IS_MAIN_BRANCH, Boolean.toString(false))))\n+      .setSize(0)\n+      .addAggregation(AggregationBuilders.terms(\"branchUuids\")\n+        .field(IssueIndexDefinition.FIELD_ISSUE_BRANCH_UUID)\n+        .size(branchUuids.size())\n+        .subAggregation(AggregationBuilders.terms(\"types\")\n+          .field(IssueIndexDefinition.FIELD_ISSUE_TYPE)));\n+    SearchResponse response = request.get();\n+    return ((StringTerms) response.getAggregations().get(\"branchUuids\")).getBuckets().stream()\n+      .map(bucket -> new BranchStatistics(bucket.getKeyAsString(),\n+        ((StringTerms) bucket.getAggregations().get(\"types\")).getBuckets()","path":"server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java","position":96,"original_position":96,"commit_id":"af4f19f917983f4d50d40dfde16af4b27121897e","original_commit_id":"af4f19f917983f4d50d40dfde16af4b27121897e","user":{"login":"SonarTech","id":1842438,"avatar_url":"https://avatars2.githubusercontent.com/u/1842438?v=4","gravatar_id":"","url":"https://api.github.com/users/SonarTech","html_url":"https://github.com/SonarTech","followers_url":"https://api.github.com/users/SonarTech/followers","following_url":"https://api.github.com/users/SonarTech/following{/other_user}","gists_url":"https://api.github.com/users/SonarTech/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarTech/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarTech/subscriptions","organizations_url":"https://api.github.com/users/SonarTech/orgs","repos_url":"https://api.github.com/users/SonarTech/repos","events_url":"https://api.github.com/users/SonarTech/events{/privacy}","received_events_url":"https://api.github.com/users/SonarTech/received_events","type":"User","site_admin":false},"body":"![MINOR](https://sonarsource.github.io/sonar-github/severity-minor.png 'Severity: MINOR') Remove this unnecessary cast to \"StringTerms\". [![rule](https://sonarsource.github.io/sonar-github/rule.png)](https://next.sonarqube.com/sonarqube/coding_rules#rule_key=squid%3AS1905)\n","created_at":"2017-08-29T14:02:30Z","updated_at":"2017-08-29T14:02:30Z","html_url":"https://github.com/SonarSource/sonarqube/pull/2448#discussion_r135798262","pull_request_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2448","_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/comments/135798262"},"html":{"href":"https://github.com/SonarSource/sonarqube/pull/2448#discussion_r135798262"},"pull_request":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2448"}}},"pull_request":{"url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2448","id":138137960,"html_url":"https://github.com/SonarSource/sonarqube/pull/2448","diff_url":"https://github.com/SonarSource/sonarqube/pull/2448.diff","patch_url":"https://github.com/SonarSource/sonarqube/pull/2448.patch","issue_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/2448","number":2448,"state":"open","locked":false,"title":"SONAR-9616 Use single ES query in api/project_branches/list","user":{"login":"julienlancelot","id":370769,"avatar_url":"https://avatars3.githubusercontent.com/u/370769?v=4","gravatar_id":"","url":"https://api.github.com/users/julienlancelot","html_url":"https://github.com/julienlancelot","followers_url":"https://api.github.com/users/julienlancelot/followers","following_url":"https://api.github.com/users/julienlancelot/following{/other_user}","gists_url":"https://api.github.com/users/julienlancelot/gists{/gist_id}","starred_url":"https://api.github.com/users/julienlancelot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julienlancelot/subscriptions","organizations_url":"https://api.github.com/users/julienlancelot/orgs","repos_url":"https://api.github.com/users/julienlancelot/repos","events_url":"https://api.github.com/users/julienlancelot/events{/privacy}","received_events_url":"https://api.github.com/users/julienlancelot/received_events","type":"User","site_admin":false},"body":"","created_at":"2017-08-29T10:07:42Z","updated_at":"2017-08-29T14:02:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"a6b16f0f1b77fe23b797cd0183236e79a68981be","assignee":{"login":"julienlancelot","id":370769,"avatar_url":"https://avatars3.githubusercontent.com/u/370769?v=4","gravatar_id":"","url":"https://api.github.com/users/julienlancelot","html_url":"https://github.com/julienlancelot","followers_url":"https://api.github.com/users/julienlancelot/followers","following_url":"https://api.github.com/users/julienlancelot/following{/other_user}","gists_url":"https://api.github.com/users/julienlancelot/gists{/gist_id}","starred_url":"https://api.github.com/users/julienlancelot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julienlancelot/subscriptions","organizations_url":"https://api.github.com/users/julienlancelot/orgs","repos_url":"https://api.github.com/users/julienlancelot/repos","events_url":"https://api.github.com/users/julienlancelot/events{/privacy}","received_events_url":"https://api.github.com/users/julienlancelot/received_events","type":"User","site_admin":false},"assignees":[{"login":"julienlancelot","id":370769,"avatar_url":"https://avatars3.githubusercontent.com/u/370769?v=4","gravatar_id":"","url":"https://api.github.com/users/julienlancelot","html_url":"https://github.com/julienlancelot","followers_url":"https://api.github.com/users/julienlancelot/followers","following_url":"https://api.github.com/users/julienlancelot/following{/other_user}","gists_url":"https://api.github.com/users/julienlancelot/gists{/gist_id}","starred_url":"https://api.github.com/users/julienlancelot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/julienlancelot/subscriptions","organizations_url":"https://api.github.com/users/julienlancelot/orgs","repos_url":"https://api.github.com/users/julienlancelot/repos","events_url":"https://api.github.com/users/julienlancelot/events{/privacy}","received_events_url":"https://api.github.com/users/julienlancelot/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2448/commits","review_comments_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2448/comments","review_comment_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/2448/comments","statuses_url":"https://api.github.com/repos/SonarSource/sonarqube/statuses/af4f19f917983f4d50d40dfde16af4b27121897e","head":{"label":"SonarSource:feature/jl/use_single_es_query_in_list_branches","ref":"feature/jl/use_single_es_query_in_list_branches","sha":"af4f19f917983f4d50d40dfde16af4b27121897e","user":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars0.githubusercontent.com/u/545988?v=4","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"repo":{"id":1222504,"name":"sonarqube","full_name":"SonarSource/sonarqube","owner":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars0.githubusercontent.com/u/545988?v=4","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarSource/sonarqube","description":"Continuous Code Quality","fork":false,"url":"https://api.github.com/repos/SonarSource/sonarqube","forks_url":"https://api.github.com/repos/SonarSource/sonarqube/forks","keys_url":"https://api.github.com/repos/SonarSource/sonarqube/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarSource/sonarqube/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarSource/sonarqube/teams","hooks_url":"https://api.github.com/repos/SonarSource/sonarqube/hooks","issue_events_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/events{/number}","events_url":"https://api.github.com/repos/SonarSource/sonarqube/events","assignees_url":"https://api.github.com/repos/SonarSource/sonarqube/assignees{/user}","branches_url":"https://api.github.com/repos/SonarSource/sonarqube/branches{/branch}","tags_url":"https://api.github.com/repos/SonarSource/sonarqube/tags","blobs_url":"https://api.github.com/repos/SonarSource/sonarqube/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarSource/sonarqube/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarSource/sonarqube/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarSource/sonarqube/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarSource/sonarqube/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarSource/sonarqube/languages","stargazers_url":"https://api.github.com/repos/SonarSource/sonarqube/stargazers","contributors_url":"https://api.github.com/repos/SonarSource/sonarqube/contributors","subscribers_url":"https://api.github.com/repos/SonarSource/sonarqube/subscribers","subscription_url":"https://api.github.com/repos/SonarSource/sonarqube/subscription","commits_url":"https://api.github.com/repos/SonarSource/sonarqube/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarSource/sonarqube/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarSource/sonarqube/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarSource/sonarqube/contents/{+path}","compare_url":"https://api.github.com/repos/SonarSource/sonarqube/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarSource/sonarqube/merges","archive_url":"https://api.github.com/repos/SonarSource/sonarqube/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarSource/sonarqube/downloads","issues_url":"https://api.github.com/repos/SonarSource/sonarqube/issues{/number}","pulls_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarSource/sonarqube/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarSource/sonarqube/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarSource/sonarqube/labels{/name}","releases_url":"https://api.github.com/repos/SonarSource/sonarqube/releases{/id}","deployments_url":"https://api.github.com/repos/SonarSource/sonarqube/deployments","created_at":"2011-01-05T11:05:17Z","updated_at":"2017-08-29T07:04:36Z","pushed_at":"2017-08-29T14:01:21Z","git_url":"git://github.com/SonarSource/sonarqube.git","ssh_url":"git@github.com:SonarSource/sonarqube.git","clone_url":"https://github.com/SonarSource/sonarqube.git","svn_url":"https://github.com/SonarSource/sonarqube","homepage":"http://www.sonarqube.org","size":217961,"stargazers_count":1972,"watchers_count":1972,"language":"Java","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":690,"mirror_url":null,"open_issues_count":22,"forks":690,"open_issues":22,"watchers":1972,"default_branch":"master"}},"base":{"label":"SonarSource:feature/branches","ref":"feature/branches","sha":"da3b85293ed02bb8b62803395bbbf08afbbe8719","user":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars0.githubusercontent.com/u/545988?v=4","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"repo":{"id":1222504,"name":"sonarqube","full_name":"SonarSource/sonarqube","owner":{"login":"SonarSource","id":545988,"avatar_url":"https://avatars0.githubusercontent.com/u/545988?v=4","gravatar_id":"","url":"https://api.github.com/users/SonarSource","html_url":"https://github.com/SonarSource","followers_url":"https://api.github.com/users/SonarSource/followers","following_url":"https://api.github.com/users/SonarSource/following{/other_user}","gists_url":"https://api.github.com/users/SonarSource/gists{/gist_id}","starred_url":"https://api.github.com/users/SonarSource/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SonarSource/subscriptions","organizations_url":"https://api.github.com/users/SonarSource/orgs","repos_url":"https://api.github.com/users/SonarSource/repos","events_url":"https://api.github.com/users/SonarSource/events{/privacy}","received_events_url":"https://api.github.com/users/SonarSource/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SonarSource/sonarqube","description":"Continuous Code Quality","fork":false,"url":"https://api.github.com/repos/SonarSource/sonarqube","forks_url":"https://api.github.com/repos/SonarSource/sonarqube/forks","keys_url":"https://api.github.com/repos/SonarSource/sonarqube/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SonarSource/sonarqube/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SonarSource/sonarqube/teams","hooks_url":"https://api.github.com/repos/SonarSource/sonarqube/hooks","issue_events_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/events{/number}","events_url":"https://api.github.com/repos/SonarSource/sonarqube/events","assignees_url":"https://api.github.com/repos/SonarSource/sonarqube/assignees{/user}","branches_url":"https://api.github.com/repos/SonarSource/sonarqube/branches{/branch}","tags_url":"https://api.github.com/repos/SonarSource/sonarqube/tags","blobs_url":"https://api.github.com/repos/SonarSource/sonarqube/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SonarSource/sonarqube/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SonarSource/sonarqube/git/refs{/sha}","trees_url":"https://api.github.com/repos/SonarSource/sonarqube/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SonarSource/sonarqube/statuses/{sha}","languages_url":"https://api.github.com/repos/SonarSource/sonarqube/languages","stargazers_url":"https://api.github.com/repos/SonarSource/sonarqube/stargazers","contributors_url":"https://api.github.com/repos/SonarSource/sonarqube/contributors","subscribers_url":"https://api.github.com/repos/SonarSource/sonarqube/subscribers","subscription_url":"https://api.github.com/repos/SonarSource/sonarqube/subscription","commits_url":"https://api.github.com/repos/SonarSource/sonarqube/commits{/sha}","git_commits_url":"https://api.github.com/repos/SonarSource/sonarqube/git/commits{/sha}","comments_url":"https://api.github.com/repos/SonarSource/sonarqube/comments{/number}","issue_comment_url":"https://api.github.com/repos/SonarSource/sonarqube/issues/comments{/number}","contents_url":"https://api.github.com/repos/SonarSource/sonarqube/contents/{+path}","compare_url":"https://api.github.com/repos/SonarSource/sonarqube/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SonarSource/sonarqube/merges","archive_url":"https://api.github.com/repos/SonarSource/sonarqube/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SonarSource/sonarqube/downloads","issues_url":"https://api.github.com/repos/SonarSource/sonarqube/issues{/number}","pulls_url":"https://api.github.com/repos/SonarSource/sonarqube/pulls{/number}","milestones_url":"https://api.github.com/repos/SonarSource/sonarqube/milestones{/number}","notifications_url":"https://api.github.com/repos/SonarSource/sonarqube/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SonarSource/sonarqube/labels{/name}","releases_url":"https://api.github.com/repos/SonarSource/sonarqube/releases{/id}","deployments_url":"https://api.github.com/repos/SonarSource/sonarqube/deployments","created_at":"2011-01-05T11:05:17Z","updated_at":"2017-08-29T07:04:36Z","pushed_at":"2017-08-29T14:01:21Z","git_url":"git://github.com/SonarSource/sonarqube.git","ssh_url":"git@github.com:SonarSource/sonarqube.git","clone_url":"https://github.com/SonarSource/sonarqube.git","svn_url":"https://github.com/SonarSource/sonarqube","homepage":"http://www.sonarqube.org","size":217961,"stargazers_count":1972,"watchers_count":1972,"language":"Java","has_issues":false,"has_projects":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":690,"mirror_url":null,"open_issues_count":22,"forks":690,"open_issues":22,"watchers":1972,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2448"},"html":{"href":"https://github.com/SonarSource/sonarqube/pull/2448"},"issue":{"href":"https://api.github.com/repos/SonarSource/sonarqube/issues/2448"},"comments":{"href":"https://api.github.com/repos/SonarSource/sonarqube/issues/2448/comments"},"review_comments":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2448/comments"},"review_comment":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SonarSource/sonarqube/pulls/2448/commits"},"statuses":{"href":"https://api.github.com/repos/SonarSource/sonarqube/statuses/af4f19f917983f4d50d40dfde16af4b27121897e"}}}}
{"actor":{"display_login":"SonarTech"}}