@@ -88,8 +88,8 @@ public class CeActivityDao implements Dao { | |||
return Optional.ofNullable(mapper(dbSession).selectLastByComponentUuidAndTaskType(componentUuid, taskType)); | |||
} | |||
public boolean hasAnyFailedIssueSyncTask(DbSession dbSession) { | |||
return mapper(dbSession).hasAnyFailedIssueSyncTask() > 0; | |||
public boolean hasAnyFailedOrCancelledIssueSyncTask(DbSession dbSession) { | |||
return mapper(dbSession).hasAnyFailedOrCancelledIssueSyncTask() > 0; | |||
} | |||
private static CeActivityMapper mapper(DbSession dbSession) { |
@@ -47,7 +47,7 @@ public interface CeActivityMapper { | |||
@CheckForNull | |||
CeActivityDto selectLastByComponentUuidAndTaskType(@Param("componentUuid") String componentUuid, @Param("taskType") String taskType); | |||
short hasAnyFailedIssueSyncTask(); | |||
short hasAnyFailedOrCancelledIssueSyncTask(); | |||
List<CeActivityDto> selectByTaskType(@Param("taskType") String taskType); | |||
} |
@@ -248,13 +248,13 @@ | |||
and ca.is_last = ${_true} | |||
</select> | |||
<sql id="hasAnyFailedIssueSyncTaskSql"> | |||
<sql id="hasAnyFailedOrCancelledIssueSyncTaskSql"> | |||
select | |||
case when exists | |||
( | |||
select ca.uuid from ce_activity ca inner join project_branches pb on ca.component_uuid = pb.uuid | |||
where ca.task_type = 'ISSUE_SYNC' | |||
and ca.status = 'FAILED' | |||
and ca.status in ('FAILED', 'CANCELED') | |||
and pb.need_issue_sync = ${_true} | |||
) | |||
then 1 | |||
@@ -262,12 +262,12 @@ | |||
end | |||
</sql> | |||
<select id="hasAnyFailedIssueSyncTask" parameterType="map" resultType="short" > | |||
<include refid="hasAnyFailedIssueSyncTaskSql"/> | |||
<select id="hasAnyFailedOrCancelledIssueSyncTask" parameterType="map" resultType="short" > | |||
<include refid="hasAnyFailedOrCancelledIssueSyncTaskSql"/> | |||
</select> | |||
<select id="hasAnyFailedIssueSyncTask" parameterType="map" resultType="short" databaseId="oracle"> | |||
<include refid="hasAnyFailedIssueSyncTaskSql"/> | |||
<select id="hasAnyFailedOrCancelledIssueSyncTask" parameterType="map" resultType="short" databaseId="oracle"> | |||
<include refid="hasAnyFailedOrCancelledIssueSyncTaskSql"/> | |||
from dual | |||
</select> | |||
@@ -762,8 +762,8 @@ public class CeActivityDaoTest { | |||
} | |||
@Test | |||
public void hasAnyFailedIssueSyncTask() { | |||
assertThat(underTest.hasAnyFailedIssueSyncTask(db.getSession())).isFalse(); | |||
public void hasAnyFailedOrCancelledIssueSyncTask() { | |||
assertThat(underTest.hasAnyFailedOrCancelledIssueSyncTask(db.getSession())).isFalse(); | |||
insert("TASK_1", REPORT, MAINCOMPONENT_1, SUCCESS); | |||
insert("TASK_2", REPORT, MAINCOMPONENT_1, FAILED); | |||
@@ -779,31 +779,40 @@ public class CeActivityDaoTest { | |||
}); | |||
insert("TASK_4", CeTaskTypes.BRANCH_ISSUE_SYNC, projectDto2.getUuid(), projectDto2.getUuid(), SUCCESS); | |||
assertThat(underTest.hasAnyFailedIssueSyncTask(db.getSession())).isFalse(); | |||
assertThat(underTest.hasAnyFailedOrCancelledIssueSyncTask(db.getSession())).isFalse(); | |||
ProjectDto projectDto3 = db.components().insertPrivateProjectDto(branchDto -> branchDto.setNeedIssueSync(false), c -> { | |||
}, p -> { | |||
}); | |||
insert("TASK_5", CeTaskTypes.BRANCH_ISSUE_SYNC, projectDto3.getUuid(), projectDto3.getUuid(), SUCCESS); | |||
BranchDto projectBranch = db.components() | |||
BranchDto projectBranch1 = db.components() | |||
.insertProjectBranch(projectDto3, branchDto -> branchDto.setNeedIssueSync(true)); | |||
insert("TASK_6", CeTaskTypes.BRANCH_ISSUE_SYNC, projectBranch.getUuid(), projectDto3.getUuid(), FAILED); | |||
insert("TASK_6", CeTaskTypes.BRANCH_ISSUE_SYNC, projectBranch1.getUuid(), projectDto3.getUuid(), FAILED); | |||
BranchDto projectBranch2 = db.components() | |||
.insertProjectBranch(projectDto3, branchDto -> branchDto.setNeedIssueSync(true)); | |||
insert("TASK_7", CeTaskTypes.BRANCH_ISSUE_SYNC, projectBranch2.getUuid(), projectDto3.getUuid(), CANCELED); | |||
// failed task and project branch still exists and need sync | |||
assertThat(underTest.hasAnyFailedIssueSyncTask(db.getSession())).isTrue(); | |||
assertThat(underTest.hasAnyFailedOrCancelledIssueSyncTask(db.getSession())).isTrue(); | |||
// assume branch has been re-analysed | |||
db.getDbClient().branchDao().updateNeedIssueSync(db.getSession(), projectBranch1.getUuid(), false); | |||
// assume branch has been re-analysed | |||
db.getDbClient().branchDao().updateNeedIssueSync(db.getSession(), projectBranch.getUuid(), false); | |||
db.getDbClient().branchDao().updateNeedIssueSync(db.getSession(), projectBranch2.getUuid(), false); | |||
assertThat(underTest.hasAnyFailedIssueSyncTask(db.getSession())).isFalse(); | |||
assertThat(underTest.hasAnyFailedOrCancelledIssueSyncTask(db.getSession())).isFalse(); | |||
// assume branch has been deleted | |||
db.getDbClient().purgeDao().deleteBranch(db.getSession(), projectBranch.getUuid()); | |||
db.getDbClient().purgeDao().deleteBranch(db.getSession(), projectBranch1.getUuid()); | |||
db.getDbClient().purgeDao().deleteBranch(db.getSession(), projectBranch2.getUuid()); | |||
// associated branch does not exist, so there is no failures - either it has been deleted or purged or reanalysed | |||
assertThat(underTest.hasAnyFailedIssueSyncTask(db.getSession())).isFalse(); | |||
assertThat(underTest.hasAnyFailedOrCancelledIssueSyncTask(db.getSession())).isFalse(); | |||
} | |||
private CeActivityDto insert(String uuid, String type, @Nullable String mainComponentUuid, CeActivityDto.Status status) { |
@@ -42,7 +42,7 @@ public class IssueIndexSyncProgressChecker { | |||
public IssueSyncProgress getIssueSyncProgress(DbSession dbSession) { | |||
int completed = dbClient.branchDao().countByNeedIssueSync(dbSession, false); | |||
boolean hasFailures = dbClient.ceActivityDao().hasAnyFailedIssueSyncTask(dbSession); | |||
boolean hasFailures = dbClient.ceActivityDao().hasAnyFailedOrCancelledIssueSyncTask(dbSession); | |||
boolean isCompleted = !dbClient.ceQueueDao().hasAnyIssueSyncTaskPendingOrInProgress(dbSession); | |||
int total = dbClient.branchDao().countAll(dbSession); | |||
return new IssueSyncProgress(isCompleted, completed, total, hasFailures); |
@@ -4119,7 +4119,7 @@ indexation.progression_with_error={0}% complete with some {link}. | |||
indexation.progression_with_error.link=tasks failing | |||
indexation.completed=All project data has been reloaded. | |||
indexation.completed_with_error=SonarQube completed the reload of project data. Some {link} causing some projects to remain unavailable. | |||
indexation.completed_with_error.link=tasks failed | |||
indexation.completed_with_error.link=tasks failed or cancelled | |||
indexation.admin_link=See {link} for more information. | |||
indexation.page_unavailable.title.issues=Issues page is temporarily unavailable | |||
indexation.page_unavailable.title.portfolios=Portfolios page is temporarily unavailable |