]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-6137 Display full selected range on issues createdAt facet
authorJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Thu, 5 Feb 2015 16:38:20 +0000 (17:38 +0100)
committerJean-Baptiste Lievremont <jean-baptiste.lievremont@sonarsource.com>
Thu, 5 Feb 2015 16:53:46 +0000 (17:53 +0100)
server/sonar-server/src/main/java/org/sonar/server/issue/index/IssueIndex.java
server/sonar-server/src/test/java/org/sonar/server/issue/index/IssueIndexMediumTest.java

index 5c8b90a744d29cf5bc2e1c9bb8c88d36a1f6631f..42064038b101b375ed4eddaa70592a13ea444b22 100644 (file)
@@ -446,6 +446,7 @@ public class IssueIndex extends BaseIndex<Issue, FakeIssueDto, String> {
         IssueFilterParameters.RULES, IssueIndexDefinition.FIELD_ISSUE_RULE_KEY, query.rules().toArray());
       addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch,
         IssueFilterParameters.REPORTERS, IssueIndexDefinition.FIELD_ISSUE_REPORTER);
+
       addSimpleStickyFacetIfNeeded(options, stickyFacetBuilder, esSearch,
         IssueFilterParameters.AUTHORS, IssueIndexDefinition.FIELD_ISSUE_AUTHOR_LOGIN, query.authors().toArray());
 
@@ -583,7 +584,8 @@ public class IssueIndex extends BaseIndex<Issue, FakeIssueDto, String> {
       .minDocCount(0L)
       .format(DateUtils.DATETIME_FORMAT)
       .preZone(timeZoneString)
-      .postZone(timeZoneString);
+      .postZone(timeZoneString)
+      .extendedBounds(startTime, endTime);
   }
 
   private long getMinCreatedAt(Map<String, FilterBuilder> filters, QueryBuilder esQuery) {
index 2e2ef0529b25cef7e0d925875b50697a0900bc49..fb39f468d5e8056e28e55529cf7daf097f87a48d 100644 (file)
@@ -652,13 +652,16 @@ public class IssueIndexMediumTest {
 
     Collection<FacetValue> createdAt = index.search(IssueQuery.builder().createdAfter(DateUtils.parseDate("2014-09-01")).createdBefore(DateUtils.parseDate("2014-09-08")).build(),
       queryContext).getFacets().get("createdAt");
-    assertThat(createdAt).hasSize(5)
+    assertThat(createdAt).hasSize(8)
       .containsOnly(
+        new FacetValue("2014-08-31T01:00:00+0000", 0),
         new FacetValue("2014-09-01T01:00:00+0000", 2),
         new FacetValue("2014-09-02T01:00:00+0000", 1),
         new FacetValue("2014-09-03T01:00:00+0000", 0),
         new FacetValue("2014-09-04T01:00:00+0000", 0),
-        new FacetValue("2014-09-05T01:00:00+0000", 1));
+        new FacetValue("2014-09-05T01:00:00+0000", 1),
+        new FacetValue("2014-09-06T01:00:00+0000", 0),
+        new FacetValue("2014-09-07T01:00:00+0000", 0));
   }
 
   @Test
@@ -668,8 +671,9 @@ public class IssueIndexMediumTest {
 
     Collection<FacetValue> createdAt = index.search(IssueQuery.builder().createdAfter(DateUtils.parseDate("2014-09-01")).createdBefore(DateUtils.parseDate("2014-09-21")).build(),
       queryContext).getFacets().get("createdAt");
-    assertThat(createdAt).hasSize(3)
+    assertThat(createdAt).hasSize(4)
       .containsOnly(
+        new FacetValue("2014-08-25T01:00:00+0000", 0),
         new FacetValue("2014-09-01T01:00:00+0000", 4),
         new FacetValue("2014-09-08T01:00:00+0000", 0),
         new FacetValue("2014-09-15T01:00:00+0000", 1));
@@ -682,8 +686,9 @@ public class IssueIndexMediumTest {
 
     Collection<FacetValue> createdAt = index.search(IssueQuery.builder().createdAfter(DateUtils.parseDate("2014-09-01")).createdBefore(DateUtils.parseDate("2015-01-19")).build(),
       queryContext).getFacets().get("createdAt");
-    assertThat(createdAt).hasSize(5)
+    assertThat(createdAt).hasSize(6)
       .containsOnly(
+        new FacetValue("2014-08-01T01:00:00+0000", 0),
         new FacetValue("2014-09-01T01:00:00+0000", 5),
         new FacetValue("2014-10-01T01:00:00+0000", 0),
         new FacetValue("2014-11-01T01:00:00+0000", 0),
@@ -698,13 +703,37 @@ public class IssueIndexMediumTest {
 
     Collection<FacetValue> createdAt = index.search(IssueQuery.builder().createdAfter(DateUtils.parseDate("2011-01-01")).createdBefore(DateUtils.parseDate("2016-01-01")).build(),
       queryContext).getFacets().get("createdAt");
-    assertThat(createdAt).hasSize(5)
+    assertThat(createdAt).hasSize(6)
       .containsOnly(
         new FacetValue("2011-01-01T01:00:00+0000", 1),
         new FacetValue("2012-01-01T01:00:00+0000", 0),
         new FacetValue("2013-01-01T01:00:00+0000", 0),
         new FacetValue("2014-01-01T01:00:00+0000", 5),
-        new FacetValue("2015-01-01T01:00:00+0000", 1));
+        new FacetValue("2015-01-01T01:00:00+0000", 1),
+        new FacetValue("2016-01-01T01:00:00+0000", 0));
+
+  }
+
+  @Test
+  public void facet_on_created_at_with_bounds_outside_of_data() throws Exception {
+
+    QueryContext queryContext = fixtureForCreatedAtFacet();
+
+    Collection<FacetValue> createdAt = index.search(IssueQuery.builder()
+        .createdAfter(DateUtils.parseDate("2009-01-01"))
+        .createdBefore(DateUtils.parseDate("2016-01-01"))
+        .build(),
+      queryContext).getFacets().get("createdAt");
+    assertThat(createdAt).hasSize(8)
+      .containsOnly(
+        new FacetValue("2009-01-01T01:00:00+0000", 0),
+        new FacetValue("2010-01-01T01:00:00+0000", 0),
+        new FacetValue("2011-01-01T01:00:00+0000", 1),
+        new FacetValue("2012-01-01T01:00:00+0000", 0),
+        new FacetValue("2013-01-01T01:00:00+0000", 0),
+        new FacetValue("2014-01-01T01:00:00+0000", 5),
+        new FacetValue("2015-01-01T01:00:00+0000", 1),
+        new FacetValue("2016-01-01T01:00:00+0000", 0));
 
   }
 
@@ -713,15 +742,17 @@ public class IssueIndexMediumTest {
 
     QueryContext queryContext = fixtureForCreatedAtFacet();
 
-    Collection<FacetValue> createdAt = index.search(IssueQuery.builder().createdBefore(DateUtils.parseDate("2016-01-01")).build(),
+    Collection<FacetValue> createdAt = index.search(IssueQuery.builder()
+      .createdBefore(DateUtils.parseDate("2016-01-01")).build(),
       queryContext).getFacets().get("createdAt");
-    assertThat(createdAt).hasSize(5)
+    assertThat(createdAt).hasSize(6)
       .containsOnly(
         new FacetValue("2011-01-01T01:00:00+0000", 1),
         new FacetValue("2012-01-01T01:00:00+0000", 0),
         new FacetValue("2013-01-01T01:00:00+0000", 0),
         new FacetValue("2014-01-01T01:00:00+0000", 5),
-        new FacetValue("2015-01-01T01:00:00+0000", 1));
+        new FacetValue("2015-01-01T01:00:00+0000", 1),
+        new FacetValue("2016-01-01T01:00:00+0000", 0));
   }
 
   protected QueryContext fixtureForCreatedAtFacet() {