]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-4301 Fix issue when sort and asc are null
authorJulien Lancelot <julien.lancelot@gmail.com>
Tue, 21 May 2013 12:34:28 +0000 (14:34 +0200)
committerJulien Lancelot <julien.lancelot@gmail.com>
Tue, 21 May 2013 12:34:28 +0000 (14:34 +0200)
sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java
sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/issues/_issues_list.html.erb

index 2fa1dba1ed13cb82d13a4062671ef91ca7924e59..fe8ba6b950ef5875f5ed78bb6ac915c872c5c118 100644 (file)
@@ -21,7 +21,6 @@
 package org.sonar.core.issue.db;
 
 import com.google.common.annotations.VisibleForTesting;
-import com.google.common.collect.ImmutableMap;
 import com.google.common.collect.Lists;
 import org.apache.ibatis.session.SqlSession;
 import org.sonar.api.BatchComponent;
@@ -37,6 +36,7 @@ import java.util.List;
 import java.util.Map;
 
 import static com.google.common.collect.Lists.newArrayList;
+import static com.google.common.collect.Maps.newHashMap;
 
 /**
  * @since 3.6
@@ -99,7 +99,7 @@ public class IssueDao implements BatchComponent, ServerComponent {
   }
 
   @VisibleForTesting
-  Collection<IssueDto> selectByIds(Collection<Long> ids, IssueQuery.Sort sort, boolean asc) {
+  Collection<IssueDto> selectByIds(Collection<Long> ids, IssueQuery.Sort sort, Boolean asc) {
     SqlSession session = mybatis.openSession();
     try {
       return selectByIds(ids, sort, asc, session);
@@ -108,12 +108,15 @@ public class IssueDao implements BatchComponent, ServerComponent {
     }
   }
 
-  public Collection<IssueDto> selectByIds(Collection<Long> ids, IssueQuery.Sort sort, boolean asc, SqlSession session) {
+  public Collection<IssueDto> selectByIds(Collection<Long> ids, IssueQuery.Sort sort, Boolean asc, SqlSession session) {
     if (ids.isEmpty()) {
       return Collections.emptyList();
     }
     Object idsPartition = Lists.partition(newArrayList(ids), 1000);
-    Map<String, Object> params = ImmutableMap.of("ids", idsPartition, "sort", sort, "asc", asc);
+    Map<String, Object> params = newHashMap();
+    params.put("ids", idsPartition);
+    params.put("sort", sort);
+    params.put("asc", asc);
     return session.selectList("org.sonar.core.issue.db.IssueMapper.selectByIds", params);
   }
 }
index 32a95978c2517fba49ecdba05c87b4cfe8178e56..ed6f8fe3c3a73e6a0635ad34d4cac93880d28bf7 100644 (file)
@@ -12,6 +12,7 @@
    search_options.delete(:period)
 
    search_options['sort'] = 'UPDATE_DATE'
+   search_options['asc'] = 'FALSE'
    if @dashboard_configuration && @dashboard_configuration.selected_period?
      search_options['createdAfter'] = Api::Utils.format_datetime(@dashboard_configuration.from_datetime)
      search_options['createdBefore'] = Api::Utils.format_datetime(DateTime.now)