]> source.dussan.org Git - sonarqube.git/commitdiff
Fix indexing of issues -> mix functional and technical dates
authorSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 5 Mar 2015 09:35:57 +0000 (10:35 +0100)
committerSimon Brandhof <simon.brandhof@sonarsource.com>
Thu, 5 Mar 2015 09:40:54 +0000 (10:40 +0100)
server/sonar-server/src/main/java/org/sonar/server/computation/step/ParseReportStep.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueDoc.java
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndexer.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexerTest.java
server/sonar-server/src/test/resources/org/sonar/server/issue/index/IssueIndexerTest/index.xml
sonar-batch-protocol/src/main/java/org/sonar/batch/protocol/output/BatchReportReader.java

index a72ec16fce23f62c3fbf5d591b8cbf9428f3e65f..08c92210404d2c1d7b8f3d2a26ad7360684cc22b 100644 (file)
@@ -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);
index fdfedca9850f7e97922ca1eef636b77ebd558900..efbe0b67abe9931a2057de65572405092063454d 100644 (file)
@@ -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;
index 011bcc1d7de576c16ba106950a58297619f7b64a..84420be5d4824dcbc4cdaa7bc72fd4f00a09e6ed 100644 (file)
@@ -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;
index f32df80aa98738ff41e275bd568b025f7ec9c5c1..03c7bbb8fc3bb7244e4c23bf16539d5dc6eb1e7a 100644 (file)
@@ -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);
 
index 4b946cdf30686332ee4b4909efebca7ee52f2752..d7e82dde47cd7dab0102512b3d884fb35dd0ce68 100644 (file)
@@ -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]"
index e1695c1bd0774efa74ff160c7719570a63e8baca..72a319a4e0986d088d2109f9911c333b441d3fca 100644 (file)
@@ -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