diff options
author | Julien Lancelot <julien.lancelot@sonarsource.com> | 2013-11-06 09:45:47 +0100 |
---|---|---|
committer | Julien Lancelot <julien.lancelot@sonarsource.com> | 2013-11-06 09:45:47 +0100 |
commit | a685bfdbf11297f4087388e4a2919053fc415b15 (patch) | |
tree | d8bf10885f05f9c85db83e52a3c5f31a4f94dcde /sonar-batch | |
parent | a55c63bff40372bef048e6018bca573ae4e42a55 (diff) | |
download | sonarqube-a685bfdbf11297f4087388e4a2919053fc415b15.tar.gz sonarqube-a685bfdbf11297f4087388e4a2919053fc415b15.zip |
SONAR-4700 Fix new measures calculation when comparing from x days
Diffstat (limited to 'sonar-batch')
3 files changed, 16 insertions, 3 deletions
diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java b/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java index f5649f2b495..ea5889dd2e9 100644 --- a/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java +++ b/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfiguration.java @@ -29,6 +29,7 @@ import org.sonar.api.resources.Project; import org.sonar.api.resources.Qualifiers; import javax.annotation.CheckForNull; + import java.util.List; import static com.google.common.collect.Lists.newLinkedList; @@ -68,11 +69,10 @@ public class TimeMachineConfiguration implements BatchExtension { @CheckForNull private Snapshot findSnapshot(Snapshot projectSnapshot) { - String hql = "from " + Snapshot.class.getSimpleName() + " where resourceId=:resourceId and (rootId=:rootSnapshotId or id=:rootSnapshotId) and last=:last"; + String hql = "from " + Snapshot.class.getSimpleName() + " where resourceId=:resourceId and (rootId=:rootSnapshotId or id=:rootSnapshotId)"; List<Snapshot> snapshots = session.createQuery(hql) .setParameter("resourceId", project.getId()) .setParameter("rootSnapshotId", projectSnapshot.getId()) - .setParameter("last", Boolean.TRUE) .setMaxResults(1) .getResultList(); diff --git a/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfigurationTest/shared.xml b/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfigurationTest/shared.xml new file mode 100644 index 00000000000..c8796e2bb80 --- /dev/null +++ b/sonar-batch/src/main/java/org/sonar/batch/components/TimeMachineConfigurationTest/shared.xml @@ -0,0 +1,12 @@ +<dataset> + + <projects long_name="[null]" id="1" scope="PRJ" kee="my:project" qualifier="LIB" name="my project as lib" + root_id="[null]" description="[null]" enabled="true" language="java" copy_resource_id="[null]" person_id="[null]"/> + + <projects long_name="[null]" id="2" scope="PRJ" kee="my:project" qualifier="TRK" name="my project" + root_id="[null]" description="[null]" enabled="true" language="java" copy_resource_id="[null]" person_id="[null]"/> + + <projects long_name="[null]" id="3" scope="DIR" kee="my:project:path/to/dir" qualifier="TRK" name="my dir" + root_id="2" description="[null]" enabled="true" language="java" copy_resource_id="[null]" person_id="[null]"/> + +</dataset> diff --git a/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java b/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java index 4b7f3c0019f..c2d0e0b2beb 100644 --- a/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java +++ b/sonar-batch/src/test/java/org/sonar/batch/components/TimeMachineConfigurationTest.java @@ -23,6 +23,7 @@ import org.junit.Before; import org.junit.Ignore; import org.junit.Test; import org.sonar.api.resources.Project; +import org.sonar.jpa.test.AbstractDbUnitTestCase; import java.util.Date; @@ -31,7 +32,7 @@ import static org.fest.assertions.Assertions.assertThat; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -public class TimeMachineConfigurationTest { +public class TimeMachineConfigurationTest extends AbstractDbUnitTestCase { private PeriodsDefinition periodsDefinition; |