aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-12-05 17:33:36 +0100
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>2016-12-05 17:33:36 +0100
commit46dc0f0590c60abfe479c95f17f11b552ad070a9 (patch)
treea20f7b83ae6cf37765454b54155cc1a81cf0042b
parent7248ea81e7ae41c3d386c424c946a7499eb9acd4 (diff)
downloadsonarqube-46dc0f0590c60abfe479c95f17f11b552ad070a9.tar.gz
sonarqube-46dc0f0590c60abfe479c95f17f11b552ad070a9.zip
SONAR-8447 avoid select to key ce_activity.is_key up to date
-rw-r--r--sonar-db/src/main/java/org/sonar/db/ce/CeActivityDao.java13
1 files changed, 5 insertions, 8 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/ce/CeActivityDao.java b/sonar-db/src/main/java/org/sonar/db/ce/CeActivityDao.java
index 91f155ee3ca..3893059b645 100644
--- a/sonar-db/src/main/java/org/sonar/db/ce/CeActivityDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/ce/CeActivityDao.java
@@ -23,7 +23,6 @@ import com.google.common.base.Optional;
import java.util.Collections;
import java.util.List;
import javax.annotation.Nullable;
-import org.apache.ibatis.session.RowBounds;
import org.sonar.api.utils.System2;
import org.sonar.db.Dao;
import org.sonar.db.DbSession;
@@ -43,15 +42,13 @@ public class CeActivityDao implements Dao {
public void insert(DbSession dbSession, CeActivityDto dto) {
dto.setCreatedAt(system2.now());
dto.setUpdatedAt(system2.now());
- dto.setIsLast(false);
- mapper(dbSession).insert(dto);
+ dto.setIsLast(dto.getStatus() != CeActivityDto.Status.CANCELED);
- List<String> uuids = mapper(dbSession).selectUuidsOfRecentlyCreatedByIsLastKey(dto.getIsLastKey(), new RowBounds(0, 1));
- // should never be empty, as a row was just inserted!
- if (!uuids.isEmpty()) {
- mapper(dbSession).updateIsLastToFalseForLastKey(dto.getIsLastKey(), dto.getUpdatedAt());
- mapper(dbSession).updateIsLastToTrueForUuid(uuids.get(0), dto.getUpdatedAt());
+ CeActivityMapper ceActivityMapper = mapper(dbSession);
+ if (dto.getIsLast()) {
+ ceActivityMapper.updateIsLastToFalseForLastKey(dto.getIsLastKey(), dto.getUpdatedAt());
}
+ ceActivityMapper.insert(dto);
}
public List<CeActivityDto> selectOlderThan(DbSession dbSession, long beforeDate) {