diff options
author | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-03-05 10:35:57 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@sonarsource.com> | 2015-03-05 10:40:54 +0100 |
commit | 29f7b15feea86c67c8e75fb89c8fa0dd4b807ba8 (patch) | |
tree | 6b6cf61af84603d1b5f9287594aa5b9de054c9b1 | |
parent | b1387c20ba29e03a20c841bb4dd17bb46a056ae6 (diff) | |
download | sonarqube-29f7b15feea86c67c8e75fb89c8fa0dd4b807ba8.tar.gz sonarqube-29f7b15feea86c67c8e75fb89c8fa0dd4b807ba8.zip |
Fix indexing of issues -> mix functional and technical dates
6 files changed, 18 insertions, 5 deletions
diff --git a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ParseReportStep.java b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ParseReportStep.java index a72ec16fce2..08c92210404 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/computation/step/ParseReportStep.java +++ b/server/sonar-server/src/main/java/org/sonar/server/computation/step/ParseReportStep.java @@ -26,6 +26,8 @@ import org.sonar.batch.protocol.output.BatchReportReader; import org.sonar.server.computation.ComputationContext; import org.sonar.server.computation.issue.IssueComputation; +import java.util.List; + public class ParseReportStep implements ComputationStep { private final IssueComputation issueComputation; @@ -51,7 +53,7 @@ public class ParseReportStep implements ComputationStep { BatchReportReader reportReader = context.getReportReader(); BatchReport.Component component = reportReader.readComponent(componentRef); if (component != null) { - Iterable<BatchReport.Issue> issues = reportReader.readComponentIssues(componentRef); + List<BatchReport.Issue> issues = reportReader.readComponentIssues(componentRef); issueComputation.processComponentIssues(context, component.getUuid(), issues); for (Integer childRef : component.getChildRefsList()) { recursivelyProcessComponent(context, childRef); diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java index fdfedca9850..efbe0b67abe 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java @@ -311,6 +311,10 @@ public class IssueDoc extends BaseDoc implements Issue { return this; } + public Date getTechnicalUpdateDate() { + return getFieldAsDate(IssueIndexDefinition.FIELD_ISSUE_TECHNICAL_UPDATED_AT); + } + public IssueDoc setTechnicalUpdateDate(@Nullable Date d) { setField(IssueIndexDefinition.FIELD_ISSUE_TECHNICAL_UPDATED_AT, d); return this; diff --git a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java index 011bcc1d7de..84420be5d48 100644 --- a/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java +++ b/server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java @@ -82,7 +82,7 @@ public class IssueIndexer extends BaseIndexer { bulk.add(newUpsertRequest(issue)); // it's more efficient to sort programmatically than in SQL on some databases (MySQL for instance) - maxDate = Math.max(maxDate, issue.updateDate().getTime()); + maxDate = Math.max(maxDate, issue.getTechnicalUpdateDate().getTime()); } bulk.stop(); return maxDate; diff --git a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java index f32df80aa98..03c7bbb8fc3 100644 --- a/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java +++ b/server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java @@ -84,6 +84,12 @@ public class IssueIndexerTest { assertThat(doc.severity()).isEqualTo("BLOCKER"); assertThat(doc.ruleKey()).isEqualTo(RuleKey.of("squid", "AvoidCycles")); + // functional date + assertThat(doc.updateDate().getTime()).isEqualTo(1368828000000L); + + // technical date + assertThat(doc.getTechnicalUpdateDate().getTime()).isEqualTo(1550000000000L); + // delete project indexer.deleteProject("THE_PROJECT", true); diff --git a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml index 4b946cdf306..d7e82dde47c 100644 --- a/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml +++ b/server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml @@ -27,8 +27,8 @@ reporter="[null]" issue_attributes="JIRA=http://jira.com" action_plan_key="[null]" - created_at="1000000000" - updated_at="2000000000" + created_at="1500000000000" + updated_at="1550000000000" issue_creation_date="1115848800000" issue_update_date="1368828000000" issue_close_date="[null]" diff --git a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java index e1695c1bd07..72a319a4e09 100644 --- a/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java +++ b/sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java @@ -26,6 +26,7 @@ import javax.annotation.CheckForNull; import java.io.File; import java.util.Collections; +import java.util.List; public class BatchReportReader { @@ -52,7 +53,7 @@ public class BatchReportReader { return null; } - public Iterable<BatchReport.Issue> readComponentIssues(int componentRef) { + public List<BatchReport.Issue> readComponentIssues(int componentRef) { File file = fileStructure.fileFor(FileStructure.Domain.ISSUES, componentRef); if (file.exists() && file.isFile()) { // all the issues are loaded in memory |