aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java4
-rw-r--r--sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java1
-rw-r--r--sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml6
-rw-r--r--sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java14
-rw-r--r--sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/select_purgeable_file_uuids.xml88
5 files changed, 3 insertions, 110 deletions
diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java
index f4ddf2478b6..e7d1fe5a945 100644
--- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java
+++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeDao.java
@@ -232,10 +232,6 @@ public class PurgeDao implements Dao {
return projects;
}
- public List<String> selectPurgeableFiles(DbSession dbSession, Long projectId) {
- return mapper(dbSession).selectPurgeableFileUuids(projectId);
- }
-
private PurgeMapper mapper(DbSession session) {
return session.getMapper(PurgeMapper.class);
}
diff --git a/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java b/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java
index b1f84d0925f..2cc04037aed 100644
--- a/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java
+++ b/sonar-db/src/main/java/org/sonar/db/purge/PurgeMapper.java
@@ -91,5 +91,4 @@ public interface PurgeMapper {
void deleteFileSourcesByUuid(String fileUuid);
- List<String> selectPurgeableFileUuids(Long projectId);
}
diff --git a/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml b/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
index 1d6bed47806..49555dd8ca5 100644
--- a/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
+++ b/sonar-db/src/main/resources/org/sonar/db/purge/PurgeMapper.xml
@@ -78,12 +78,6 @@
and not exists(select s.project_id from snapshots s where s.islast=${_true} and s.project_id=p.id)
</select>
- <select id="selectPurgeableFileUuids" resultType="string" parameterType="long">
- select p.uuid from projects p
- where (p.id=#{id} or p.root_id=#{id}) and p.enabled=${_true} and p.scope='FIL'
- and not exists(select s.project_id from snapshots s where s.islast=${_true} and s.project_id=p.id)
- </select>
-
<select id="selectMetricIdsWithoutHistoricalData" resultType="long">
select id from metrics where delete_historical_data=${_true}
</select>
diff --git a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
index 6f1f5e0e336..b981084b439 100644
--- a/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
+++ b/sonar-db/src/test/java/org/sonar/db/purge/PurgeDaoTest.java
@@ -66,7 +66,7 @@ public class PurgeDaoTest {
@Test
public void shouldDeleteHistoricalDataOfDirectoriesAndFiles() {
dbTester.prepareDbUnit(getClass(), "shouldDeleteHistoricalDataOfDirectoriesAndFiles.xml");
- sut.purge(new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[]{Scopes.DIRECTORY, Scopes.FILE}, 30), PurgeListener.EMPTY, new PurgeProfiler());
+ sut.purge(new PurgeConfiguration(new IdUuidPair(1L, "1"), new String[] {Scopes.DIRECTORY, Scopes.FILE}, 30), PurgeListener.EMPTY, new PurgeProfiler());
dbTester.assertDbUnit(getClass(), "shouldDeleteHistoricalDataOfDirectoriesAndFiles-result.xml", "projects", "snapshots");
}
@@ -75,7 +75,8 @@ public class PurgeDaoTest {
dbTester.prepareDbUnit(getClass(), "disable_resources_without_last_snapshot.xml");
when(system2.now()).thenReturn(1450000000000L);
sut.purge(newConfigurationWith30Days(system2), PurgeListener.EMPTY, new PurgeProfiler());
- dbTester.assertDbUnit(getClass(), "disable_resources_without_last_snapshot-result.xml", new String[]{"issue_close_date", "issue_update_date"}, "projects", "snapshots", "issues");
+ dbTester.assertDbUnit(getClass(), "disable_resources_without_last_snapshot-result.xml", new String[] {"issue_close_date", "issue_update_date"}, "projects", "snapshots",
+ "issues");
}
@Test
@@ -125,15 +126,6 @@ public class PurgeDaoTest {
dbTester.assertDbUnit(getClass(), "should_delete_all_closed_issues-result.xml", "issues", "issue_changes");
}
- @Test
- public void select_purgeable_file_uuids_and_only_them() {
- dbTester.prepareDbUnit(getClass(), "select_purgeable_file_uuids.xml");
-
- List<String> uuids = sut.selectPurgeableFiles(dbTester.getSession(), 1L);
-
- assertThat(uuids).containsOnly("GHIJ");
- }
-
private static PurgeableSnapshotDto getById(List<PurgeableSnapshotDto> snapshots, long id) {
for (PurgeableSnapshotDto snapshot : snapshots) {
if (snapshot.getSnapshotId() == id) {
diff --git a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/select_purgeable_file_uuids.xml b/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/select_purgeable_file_uuids.xml
deleted file mode 100644
index b3bca4514fb..00000000000
--- a/sonar-db/src/test/resources/org/sonar/db/purge/PurgeDaoTest/select_purgeable_file_uuids.xml
+++ /dev/null
@@ -1,88 +0,0 @@
-<dataset>
-
- <!-- the project -->
- <projects id="1" enabled="[true]" root_id="[null]" uuid="ABCD" project_uuid="ABCD" module_uuid="[null]"
- module_uuid_path="." created_at="[null]"
- long_name="[null]" scope="PRJ" qualifier="TRK" kee="project" name="project"
- description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]"
- deprecated_kee="[null]" authorization_updated_at="[null]"/>
-
- <!-- the directory -->
- <projects id="2" enabled="[true]" root_id="1" uuid="EFGH" project_uuid="ABCD" module_uuid="ABCD"
- module_uuid_path="." created_at="[null]"
- long_name="[null]" scope="DIR" qualifier="DIR" kee="project:my/dir" name="my/dir"
- description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]"
- deprecated_kee="[null]" authorization_updated_at="[null]"/>
-
- <!-- the files -->
- <projects id="3" enabled="[true]" root_id="1" uuid="GHIJ" project_uuid="ABCD" module_uuid="ABCD"
- module_uuid_path=".ABCD." created_at="[null]"
- long_name="[null]" scope="FIL" qualifier="FIL" kee="project:my/dir/File.java" name="my/dir/File.java"
- description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]"
- deprecated_kee="[null]" authorization_updated_at="[null]"/>
- <projects id="4" enabled="[true]" root_id="1" uuid="KLMN" project_uuid="ABCD" module_uuid="ABCD"
- module_uuid_path=".ABCD." created_at="[null]"
- long_name="[null]" scope="FIL" qualifier="FIL" kee="project:my/dir/File.java"
- name="my/dir/File.java"
- description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]"
- deprecated_kee="[null]" authorization_updated_at="[null]"/>
- <!-- the file has already been disabled. It should not be selected -->
- <projects id="5" enabled="[false]" root_id="1" uuid="OPQR" project_uuid="ABCD" module_uuid="ABCD"
- module_uuid_path=".ABCD." created_at="[null]"
- long_name="[null]" scope="FIL" qualifier="FIL" kee="project:my/dir/File.java"
- name="my/dir/File.java"
- description="[null]" language="java" copy_resource_id="[null]" person_id="[null]" path="[null]"
- deprecated_kee="[null]" authorization_updated_at="[null]"/>
-
- <snapshots id="1"
- project_id="1" parent_snapshot_id="[null]" root_project_id="1" root_snapshot_id="[null]"
- status="P" islast="[true]" purge_status="[null]"
- period1_mode="[null]" period1_param="[null]" period1_date="[null]"
- period2_mode="[null]" period2_param="[null]" period2_date="[null]"
- period3_mode="[null]" period3_param="[null]" period3_date="[null]"
- period4_mode="[null]" period4_param="[null]" period4_date="[null]"
- period5_mode="[null]" period5_param="[null]" period5_date="[null]"
- depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000"
- build_date="1228222680000" version="[null]" path="[null]"/>
-
- <snapshots id="2"
- project_id="2" parent_snapshot_id="1" root_project_id="1" root_snapshot_id="1"
- status="P" islast="[true]" purge_status="[null]"
- period1_mode="[null]" period1_param="[null]" period1_date="[null]"
- period2_mode="[null]" period2_param="[null]" period2_date="[null]"
- period3_mode="[null]" period3_param="[null]" period3_date="[null]"
- period4_mode="[null]" period4_param="[null]" period4_date="[null]"
- period5_mode="[null]" period5_param="[null]" period5_date="[null]"
- depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000"
- build_date="1228222680000" version="[null]" path="[null]"/>
-
- <!-- isLast is false -->
- <snapshots id="3"
- project_id="3" parent_snapshot_id="2" root_project_id="1" root_snapshot_id="1"
- status="P" islast="[false]" purge_status="[null]"
- period1_mode="[null]" period1_param="[null]" period1_date="[null]"
- period2_mode="[null]" period2_param="[null]" period2_date="[null]"
- period3_mode="[null]" period3_param="[null]" period3_date="[null]"
- period4_mode="[null]" period4_param="[null]" period4_date="[null]"
- period5_mode="[null]" period5_param="[null]" period5_date="[null]"
- depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000"
- build_date="1228222680000" version="[null]" path="[null]"/>
-
- <snapshots id="4"
- project_id="4" parent_snapshot_id="2" root_project_id="1" root_snapshot_id="1"
- status="P" islast="[true]" purge_status="[null]"
- period1_mode="[null]" period1_param="[null]" period1_date="[null]"
- period2_mode="[null]" period2_param="[null]" period2_date="[null]"
- period3_mode="[null]" period3_param="[null]" period3_date="[null]"
- period4_mode="[null]" period4_param="[null]" period4_date="[null]"
- period5_mode="[null]" period5_param="[null]" period5_date="[null]"
- depth="[null]" scope="PRJ" qualifier="TRK" created_at="1228222680000"
- build_date="1228222680000" version="[null]" path="[null]"/>
-
- <file_sources id="1" project_uuid="ABCD" file_uuid="GHIJ" binary_data="[null]" line_hashes="[null]"
- data_hash="321654987"
- created_at="123456789" updated_at="123456789" data_type="SOURCE"/>
- <file_sources id="2" project_uuid="ABCD" file_uuid="KLMN" binary_data="[null]" line_hashes="[null]"
- data_hash="321654988"
- created_at="123456789" updated_at="123456789" data_type="SOURCE"/>
-</dataset>