private final IssueIndexSyncProgressChecker issueIndexSyncProgressChecker;
public SearchProjectsAction(DbClient dbClient, ProjectMeasuresIndex index, UserSession userSession,
- ProjectsInWarning projectsInWarning,
- PlatformEditionProvider editionProvider,
- IssueIndexSyncProgressChecker issueIndexSyncProgressChecker) {
+ ProjectsInWarning projectsInWarning,
+ PlatformEditionProvider editionProvider,
+ IssueIndexSyncProgressChecker issueIndexSyncProgressChecker) {
this.dbClient = dbClient;
this.index = index;
this.userSession = userSession;
Map<String, OrganizationDto> organizationsByUuid = dbClient.organizationDao().selectByUuids(dbSession, organizationUuids)
.stream()
.collect(MoreCollectors.uniqueIndex(OrganizationDto::getUuid));
- return buildResponse(request, searchResults, organizationsByUuid);
+ boolean needIssueSync = dbClient.branchDao().hasAnyBranchWhereNeedIssueSync(dbSession, true);
+ return buildResponse(request, searchResults, organizationsByUuid, needIssueSync);
}
private SearchProjectsWsResponse handleForOrganization(DbSession dbSession, SearchProjectsRequest request, OrganizationDto organization) {
SearchResults searchResults = searchData(dbSession, request, organization);
- return buildResponse(request, searchResults, ImmutableMap.of(organization.getUuid(), organization));
+ boolean needIssueSync = dbClient.branchDao().hasAnyBranchWhereNeedIssueSync(dbSession, true);
+ return buildResponse(request, searchResults, ImmutableMap.of(organization.getUuid(), organization), needIssueSync);
}
private SearchResults searchData(DbSession dbSession, SearchProjectsRequest request, @Nullable OrganizationDto organization) {
return request.build();
}
- private SearchProjectsWsResponse buildResponse(SearchProjectsRequest request, SearchResults searchResults, Map<String, OrganizationDto> organizationsByUuid) {
- Function<ProjectDto, Component> dbToWsComponent = new DbToWsComponent(request, organizationsByUuid, searchResults, userSession.isLoggedIn());
+ private SearchProjectsWsResponse buildResponse(SearchProjectsRequest request, SearchResults searchResults, Map<String, OrganizationDto> organizationsByUuid,
+ boolean needIssueSync) {
+ Function<ProjectDto, Component> dbToWsComponent = new DbToWsComponent(request, organizationsByUuid, searchResults, userSession.isLoggedIn(), needIssueSync);
Map<String, OrganizationDto> organizationsByUuidForAdditionalInfo = new HashMap<>();
if (request.additionalFields.contains(ORGANIZATIONS)) {
private final boolean isUserLoggedIn;
private final Map<String, SnapshotDto> analysisByProjectUuid;
private final Map<String, Long> applicationsLeakPeriod;
+ private final boolean needIssueSync;
- private DbToWsComponent(SearchProjectsRequest request, Map<String, OrganizationDto> organizationsByUuid, SearchResults searchResults, boolean isUserLoggedIn) {
+ private DbToWsComponent(SearchProjectsRequest request, Map<String, OrganizationDto> organizationsByUuid, SearchResults searchResults, boolean isUserLoggedIn,
+ boolean needIssueSync) {
this.request = request;
this.analysisByProjectUuid = searchResults.analysisByProjectUuid;
this.applicationsLeakPeriod = searchResults.applicationsLeakPeriods;
this.favoriteProjectUuids = searchResults.favoriteProjectUuids;
this.projectsWithIssuesInSync = searchResults.projectsWithIssuesInSync;
this.isUserLoggedIn = isUserLoggedIn;
+ this.needIssueSync = needIssueSync;
}
@Override
wsComponent.setIsFavorite(favoriteProjectUuids.contains(dbProject.getUuid()));
}
- wsComponent.setNeedIssueSync(projectsWithIssuesInSync.contains(dbProject.getUuid()));
-
+ if (Qualifiers.APP.equals(dbProject.getQualifier())) {
+ wsComponent.setNeedIssueSync(needIssueSync);
+ } else {
+ wsComponent.setNeedIssueSync(projectsWithIssuesInSync.contains(dbProject.getUuid()));
+ }
return wsComponent.build();
}
}
public class ShowAction implements ComponentsWsAction {
private static final Set<String> PROJECT_OR_APP_QUALIFIERS = ImmutableSet.of(Qualifiers.PROJECT, Qualifiers.APP);
- private static final Set<String> VIEW_OR_SUBVIEW_QUALIFIERS = ImmutableSet.of(Qualifiers.VIEW, Qualifiers.SUBVIEW);
+ private static final Set<String> APP_VIEW_OR_SUBVIEW_QUALIFIERS = ImmutableSet.of(Qualifiers.APP, Qualifiers.VIEW, Qualifiers.SUBVIEW);
private final UserSession userSession;
private final DbClient dbClient;
private final ComponentFinder componentFinder;
}
private boolean needIssueSync(DbSession dbSession, ComponentDto component, @Nullable ProjectDto projectDto) {
- if (projectDto == null || VIEW_OR_SUBVIEW_QUALIFIERS.contains(component.qualifier())) {
+ if (projectDto == null || APP_VIEW_OR_SUBVIEW_QUALIFIERS.contains(component.qualifier())) {
return issueIndexSyncProgressChecker.isIssueSyncInProgress(dbSession);
}
-
return issueIndexSyncProgressChecker.doProjectNeedIssueSync(dbSession, projectDto.getUuid());
}