From 50b12df3787d87958fcef7fbf8c00598b141f1ee Mon Sep 17 00:00:00 2001 From: Duarte Meneses Date: Fri, 30 Sep 2022 12:23:26 -0500 Subject: SONAR-17352 Refactor component keys to not include branch suffix --- .../sonar/server/issue/index/IssueQueryFactory.java | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'server/sonar-webserver-es') diff --git a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java index 22d72c4b921..fc53b893444 100644 --- a/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java +++ b/server/sonar-webserver-es/src/main/java/org/sonar/server/issue/index/IssueQueryFactory.java @@ -420,14 +420,7 @@ public class IssueQueryFactory { } private List getComponentsFromKeys(DbSession dbSession, Collection componentKeys, @Nullable String branch, @Nullable String pullRequest) { - List componentDtos; - if (branch != null) { - componentDtos = dbClient.componentDao().selectByKeysAndBranch(dbSession, componentKeys, branch); - } else if (pullRequest != null) { - componentDtos = dbClient.componentDao().selectByKeysAndPullRequest(dbSession, componentKeys, pullRequest); - } else { - componentDtos = dbClient.componentDao().selectByKeys(dbSession, componentKeys); - } + List componentDtos = dbClient.componentDao().selectByKeys(dbSession, componentKeys, branch, pullRequest); if (!componentKeys.isEmpty() && componentDtos.isEmpty()) { return singletonList(UNKNOWN_COMPONENT); } @@ -456,12 +449,12 @@ public class IssueQueryFactory { private void setBranch(IssueQuery.Builder builder, ComponentDto component, @Nullable String branch, @Nullable String pullRequest, DbSession session) { - BranchDto branchDto = findComponentBranch(session, component); - String componentBranch = branchDto.isMain() ? null : branchDto.getBranchKey(); builder.branchUuid(branch == null && pullRequest == null ? null : component.branchUuid()); - builder.mainBranch(UNKNOWN_COMPONENT.equals(component) - || (branch == null && pullRequest == null) - || (branch != null && !branch.equals(componentBranch)) - || (pullRequest != null && !pullRequest.equals(branchDto.getPullRequestKey()))); + if (UNKNOWN_COMPONENT.equals(component) || (pullRequest == null && branch == null)) { + builder.mainBranch(true); + } else { + BranchDto branchDto = findComponentBranch(session, component); + builder.mainBranch(branchDto.isMain()); + } } } -- cgit v1.2.3