From cad21a041f6d4727e3cd92f25aef5f4939ad667a Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Tue, 7 Feb 2012 23:18:34 +0100 Subject: [PATCH] SONAR-2756 Purge measures related to quality model requirements --- .../java/org/sonar/core/purge/PurgeDao.java | 1 + .../org/sonar/core/purge/PurgeMapper.java | 2 + .../org/sonar/core/purge/PurgeMapper.xml | 7 +- ...stedMeasuresWhenPurgingSnapshot-result.xml | 76 +++++++++++++------ ...eleteWastedMeasuresWhenPurgingSnapshot.xml | 66 +++++++++++----- 5 files changed, 110 insertions(+), 42 deletions(-) diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java index baf8fc38680..fbf5f663e79 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeDao.java @@ -179,6 +179,7 @@ public class PurgeDao { mapper.deleteSnapshotSource(snapshotId); mapper.deleteSnapshotViolations(snapshotId); mapper.deleteSnapshotWastedMeasures(snapshotId); + mapper.deleteSnapshotMeasuresOnQualityModelRequirements(snapshotId); mapper.updatePurgeStatusToOne(snapshotId); } diff --git a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java index 4aa251a7437..3eb54da5b9b 100644 --- a/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java +++ b/sonar-core/src/main/java/org/sonar/core/purge/PurgeMapper.java @@ -45,6 +45,8 @@ public interface PurgeMapper { void deleteSnapshotWastedMeasures(long snapshotId); + void deleteSnapshotMeasuresOnQualityModelRequirements(long snapshotId); + void updatePurgeStatusToOne(long snapshotId); void disableResource(long resourceId); diff --git a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml index de31a052238..38ef704ed70 100644 --- a/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml +++ b/sonar-core/src/main/resources/org/sonar/core/purge/PurgeMapper.xml @@ -111,10 +111,15 @@ delete from project_measures where snapshot_id=#{id} and - (characteristic_id is not null or rule_id is not null or metric_id in (select id from metrics where + (rule_id is not null or metric_id in (select id from metrics where delete_historical_data=${_true})) + + delete from project_measures where snapshot_id=#{id} and + characteristic_id in (select id from characteristics where rule_id is not null) + + update snapshots set purge_status = 1 where id = #{id} diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml index b85e127f0c2..3ada3c43bdd 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot-result.xml @@ -1,13 +1,20 @@ diff --git a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml index da5222a4a64..297829d1f12 100644 --- a/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml +++ b/sonar-core/src/test/resources/org/sonar/core/purge/PurgeDaoTest/shouldDeleteWastedMeasuresWhenPurgingSnapshot.xml @@ -1,13 +1,20 @@ -- 2.39.5