]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4563 Use strict comparison for createdAfter in the Issues search engine
authorSimon Brandhof <simon.brandhof@gmail.com>
Mon, 12 Aug 2013 15:28:12 +0000 (17:28 +0200)
committerSimon Brandhof <simon.brandhof@gmail.com>
Mon, 12 Aug 2013 15:35:25 +0000 (17:35 +0200)
12 files changed:
plugins/sonar-core-plugin/src/main/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplate.java
plugins/sonar-core-plugin/src/main/resources/org/sonar/l10n/core.properties
plugins/sonar-core-plugin/src/main/resources/org/sonar/plugins/core/widgets/issues/unresolved_issues_per_assignee.html.erb
plugins/sonar-core-plugin/src/test/java/org/sonar/plugins/core/issue/notification/NewIssuesEmailTemplateTest.java
sonar-core/src/main/resources/org/sonar/core/issue/db/IssueMapper.xml
sonar-core/src/test/java/org/sonar/core/issue/db/IssueDaoTest.java
sonar-core/src/test/resources/org/sonar/core/issue/db/IssueDaoTest/should_select_by_date_creation.xml
sonar-plugin-api/src/main/java/org/sonar/api/issue/IssueQuery.java
sonar-plugin-api/src/main/java/org/sonar/api/issue/RubyIssueService.java
sonar-server/src/main/java/org/sonar/server/issue/IssueFilterParameters.java
sonar-server/src/main/java/org/sonar/server/issue/PublicRubyIssueService.java
sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/issues/_issues_list.html.erb

index 1c7840a91d614adfe124fa80a69769382a0073bc..fa3c0e70880d2628463a4e6e380283f72ce8c62f 100644 (file)
@@ -68,7 +68,7 @@ public class NewIssuesEmailTemplate extends EmailTemplate {
     String dateString = notification.getFieldValue("projectDate");
     if (projectKey != null && dateString != null) {
       Date date = DateUtils.parseDateTime(dateString);
-      String url = String.format("%s/issues/search?componentRoots=%s&createdAtOrAfter=%s",
+      String url = String.format("%s/issues/search?componentRoots=%s&createdAt=%s",
         settings.getServerBaseURL(), encode(projectKey), encode(DateUtils.formatDateTime(date)));
       sb.append("\n").append("See it in SonarQube: ").append(url).append("\n");
     }
index a1fd72fa50bf2e302a20a3d904d5632e77ee39af..21d6117d9e0aac329652198d83b0fea9a45ad3c5 100644 (file)
@@ -556,7 +556,7 @@ issue_filter.are_you_sure_want_delete_filter_x=Are you sure that you want to del
 issue_filter.private=Private
 issue_filter.shared_with_all_users=Shared with all users
 issue_filter.sharing=Sharing
-
+issue_filter.no_issues=No issues
 
 #------------------------------------------------------------------------------
 #
@@ -1039,7 +1039,6 @@ widget.hotspot_most_violated_resources.property.numberOfLines.name=Number of lin
 
 widget.my_reviews.name=My Unresolved Issues
 widget.my_reviews.description=Shows unresolved issues assigned to the current user.
-widget.my_reviews.no_issue=No issue.
 widget.my_reviews.property.numberOfLines.name=Number of lines
 widget.my_reviews.property.numberOfLines.desc=Maximum number of issues displayed at the same time.
 
index 46662763c637ce445cf40b28bf9589af67e14440..08ba140c521410f8f1475792dc3945ddbbd9298d 100644 (file)
@@ -35,7 +35,7 @@
 <h3><%= message('widget.reviews_per_developer.name') -%></h3>
 
 <% if assignees.size ==0 %>
-  <span class="empty_widget"><%= message('widget.reviews_per_developer.name') -%></span>
+  <span class="empty_widget"><%= message('issue_filter.no_issues') -%></span>
 
 <% else %>
 <div id="<%= div_id -%>">
index 70e4198b9eedb393e48fad1545d3779a4648bbd4..f46723272ab111b36178f0f86ccad483cfed4835 100644 (file)
@@ -73,7 +73,7 @@ public class NewIssuesEmailTemplateTest {
       "Project: Struts\n" +
       "32 new issues\n" +
       "\n" +
-      "See it in SonarQube: http://nemo.sonarsource.org/issues/search?componentRoots=org.apache%3Astruts&createdAtOrAfter=2010-05-18T16%3A50%3A45%2B0200\n");
+      "See it in SonarQube: http://nemo.sonarsource.org/issues/search?componentRoots=org.apache%3Astruts&createdAt=2010-05-18T16%3A50%3A45%2B0200\n");
   }
 
   @Test
index e2c55b4aa9295f3cd004960624830d96696ba12c..2aca03357aaadc86f7c0a267c8a5a32e773a004e 100644 (file)
       <if test="query.createdAfter() != null">
         and i.issue_creation_date &gt; #{query.createdAfter}
       </if>
-      <if test="query.createdAtOrAfter() != null">
-        and i.issue_creation_date &gt;= #{query.createdAtOrAfter}
+      <if test="query.createdAt() != null">
+        and i.issue_creation_date = #{query.createdAt}
       </if>
       <if test="query.createdBefore() != null">
         and i.issue_creation_date &lt; #{query.createdBefore}
index b8fdb2977bc44202235d81f1a9f92a281ab0694d..10416af743520acdd212f01ca0d79820e70a27ec 100644 (file)
@@ -120,16 +120,31 @@ public class IssueDaoTest extends AbstractDaoTestCase {
   public void should_select_by_date_creation() {
     setupData("shared", "should_select_by_date_creation");
 
+    // created after, strictly
     IssueQuery query = IssueQuery.builder().createdAfter(DateUtils.parseDate("2013-04-15")).build();
     assertThat(dao.selectIssueIds(query)).hasSize(1);
     assertThat(dao.selectIssueIds(query).get(0).getId()).isEqualTo(100L);
 
-    query = IssueQuery.builder().createdAtOrAfter(DateUtils.parseDate("2013-04-15")).build();
+    query = IssueQuery.builder().createdAfter(DateUtils.parseDate("2022-01-01")).build();
+    assertThat(dao.selectIssueIds(query)).isEmpty();
+
+
+    // created at a given date
+    query = IssueQuery.builder().createdAt(DateUtils.parseDate("2013-04-16")).build();
     assertThat(dao.selectIssueIds(query)).hasSize(1);
     assertThat(dao.selectIssueIds(query).get(0).getId()).isEqualTo(100L);
 
-    query = IssueQuery.builder().createdBefore(DateUtils.parseDate("2013-04-17")).requiredRole("user").build();
-    assertThat(dao.selectIssueIds(query)).hasSize(2);
+    query = IssueQuery.builder().createdAt(DateUtils.parseDate("2010-01-01")).build();
+    assertThat(dao.selectIssueIds(query)).isEmpty();
+
+
+    // created before
+    query = IssueQuery.builder().createdBefore(DateUtils.parseDate("2013-04-14")).build();
+    assertThat(dao.selectIssueIds(query)).hasSize(1);
+    assertThat(dao.selectIssueIds(query).get(0).getId()).isEqualTo(101L);
+
+    query = IssueQuery.builder().createdBefore(DateUtils.parseDate("2010-01-01")).build();
+    assertThat(dao.selectIssueIds(query)).isEmpty();
   }
 
   @Test
index cf6048a5e833c44da545954c2d4ef6fe11d6cf09..cd509c70d50673a77570b527b8242244130d7ee4 100644 (file)
@@ -18,7 +18,7 @@
       assignee="perceval"
       author_login="[null]"
       issue_attributes="JIRA=FOO-1234"
-      issue_creation_date="2013-04-16 15:50:45"
+      issue_creation_date="2013-04-16"
       issue_update_date="2013-04-16"
       issue_close_date="2013-04-16"
       created_at="2013-04-16"
index d7ce899c4f8c2d6b659775e9891c61672874771f..9826894fc23c5aa5e348fa5589f6b72542918e31 100644 (file)
@@ -70,7 +70,7 @@ public class IssueQuery {
   private final Boolean assigned;
   private final Boolean planned;
   private final Boolean resolved;
-  private final Date createdAtOrAfter;
+  private final Date createdAt;
   private final Date createdAfter;
   private final Date createdBefore;
   private final String sort;
@@ -97,7 +97,7 @@ public class IssueQuery {
     this.assigned = builder.assigned;
     this.planned = builder.planned;
     this.resolved = builder.resolved;
-    this.createdAtOrAfter = builder.createdAtOrAfter;
+    this.createdAt = builder.createdAt;
     this.createdAfter = builder.createdAfter;
     this.createdBefore = builder.createdBefore;
     this.sort = builder.sort;
@@ -168,8 +168,8 @@ public class IssueQuery {
   }
 
   @CheckForNull
-  public Date createdAtOrAfter() {
-    return (createdAtOrAfter == null ? null : new Date(createdAtOrAfter.getTime()));
+  public Date createdAt() {
+    return (createdAt == null ? null : new Date(createdAt.getTime()));
   }
 
   @CheckForNull
@@ -226,7 +226,7 @@ public class IssueQuery {
     private Boolean assigned = null;
     private Boolean planned = null;
     private Boolean resolved = null;
-    private Date createdAtOrAfter;
+    private Date createdAt;
     private Date createdAfter;
     private Date createdBefore;
     private String sort;
@@ -315,8 +315,8 @@ public class IssueQuery {
       return this;
     }
 
-    public Builder createdAtOrAfter(@Nullable Date d) {
-      this.createdAtOrAfter = (d == null ? null : new Date(d.getTime()));
+    public Builder createdAt(@Nullable Date d) {
+      this.createdAt = (d == null ? null : new Date(d.getTime()));
       return this;
     }
 
index 1afd5e480ee5a26578f82d57e985c9abf851de7e..26bea532febc91067677c907746c174ce321b144 100644 (file)
@@ -65,7 +65,7 @@ public interface RubyIssueService extends ServerComponent {
    *   <li>'assigned': true to get only assigned issues, false to get only unassigned issues. By default no filtering is done.</li>
    *   <li>'createdAfter': match all the issues created after the given date (strictly).
    *   Both date and datetime ISO formats are supported: 2013-05-18 or 2010-05-18T15:50:45+0100</li>
-   *   <li>'createdAtOrAfter': match all the issues created after the given date (inclusive).
+   *   <li>'createdAt': match all the issues created at the given date (require second precision).
    *   Both date and datetime ISO formats are supported: 2013-05-18 or 2010-05-18T15:50:45+0100</li>
    *   <li>'createdBefore': match all the issues created before the given date (exclusive).
    *   Both date and datetime ISO formats are supported: 2013-05-18 or 2010-05-18T15:50:45+0100</li>
index d1101062bf5923189c3f1549a26f5549b5d89a9d..12ec6819dadc71e10cdd308ccb1991faf155bd77 100644 (file)
@@ -47,7 +47,7 @@ public class IssueFilterParameters {
   public static final String ASSIGNED = "assigned";
   public static final String PLANNED = "planned";
   public static final String CREATED_AFTER = "createdAfter";
-  public static final String CREATED_AT_OR_AFTER = "createdAtOrAfter";
+  public static final String CREATED_AT = "createdAt";
   public static final String CREATED_BEFORE = "createdBefore";
   public static final String PAGE_SIZE = "pageSize";
   public static final String PAGE_INDEX = "pageIndex";
@@ -55,7 +55,7 @@ public class IssueFilterParameters {
   public static final String ASC = "asc";
 
   public static final List<String> ALL = ImmutableList.of(ISSUES, SEVERITIES, STATUSES, RESOLUTIONS, RESOLVED, COMPONENTS, COMPONENT_ROOTS, RULES, ACTION_PLANS, REPORTERS,
-    ASSIGNEES, ASSIGNED, PLANNED, CREATED_AFTER, CREATED_BEFORE, PAGE_SIZE, PAGE_INDEX, SORT, ASC);
+    ASSIGNEES, ASSIGNED, PLANNED, CREATED_AT, CREATED_AFTER, CREATED_BEFORE, PAGE_SIZE, PAGE_INDEX, SORT, ASC);
 
   public static final List<String> ALL_WITHOUT_PAGINATION = newArrayList(Iterables.filter(ALL, new Predicate<String>() {
     @Override
index 9f39ad2c2fe0587628f7914fa4dd7e4a0046bab0..768ac48487912552f9a8e0644b087b6d49117fdf 100644 (file)
@@ -88,7 +88,7 @@ public class PublicRubyIssueService implements RubyIssueService {
       .assignees(RubyUtils.toStrings(props.get(IssueFilterParameters.ASSIGNEES)))
       .assigned(RubyUtils.toBoolean(props.get(IssueFilterParameters.ASSIGNED)))
       .planned(RubyUtils.toBoolean(props.get(IssueFilterParameters.PLANNED)))
-      .createdAtOrAfter(RubyUtils.toDate(props.get(IssueFilterParameters.CREATED_AT_OR_AFTER)))
+      .createdAt(RubyUtils.toDate(props.get(IssueFilterParameters.CREATED_AT)))
       .createdAfter(RubyUtils.toDate(props.get(IssueFilterParameters.CREATED_AFTER)))
       .createdBefore(RubyUtils.toDate(props.get(IssueFilterParameters.CREATED_BEFORE)))
       .pageSize(RubyUtils.toInteger(props.get(IssueFilterParameters.PAGE_SIZE)))
index feb14531f348b0c92157e5990baf750f98ee02c2..f061f92f74bd0b4b59e2edcc4dddf047cafd25cd 100644 (file)
@@ -23,7 +23,7 @@
 %>
 
 <% if paging.total() == 0 %>
-  <span class="empty_widget"><%= message('widget.my_reviews.no_issue') -%></span>
+  <span class="empty_widget"><%= message('issue_filter.no_issues') -%></span>
 
 <% else %>
   <table id="issues-widget-list-<%= widget_id -%>" class="data width100">