From 2801f02b86920a00d51e8d94e8c196f637e5ac14 Mon Sep 17 00:00:00 2001 From: Julien Lancelot Date: Tue, 21 May 2013 14:34:28 +0200 Subject: [PATCH] SONAR-4301 Fix issue when sort and asc are null --- .../main/java/org/sonar/core/issue/db/IssueDao.java | 11 +++++++---- .../project/widgets/issues/_issues_list.html.erb | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java index 2fa1dba1ed1..fe8ba6b950e 100644 --- a/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java +++ b/sonar-core/src/main/java/org/sonar/core/issue/db/IssueDao.java @@ -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 selectByIds(Collection ids, IssueQuery.Sort sort, boolean asc) { + Collection selectByIds(Collection 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 selectByIds(Collection ids, IssueQuery.Sort sort, boolean asc, SqlSession session) { + public Collection selectByIds(Collection ids, IssueQuery.Sort sort, Boolean asc, SqlSession session) { if (ids.isEmpty()) { return Collections.emptyList(); } Object idsPartition = Lists.partition(newArrayList(ids), 1000); - Map params = ImmutableMap.of("ids", idsPartition, "sort", sort, "asc", asc); + Map 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); } } diff --git a/sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/issues/_issues_list.html.erb b/sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/issues/_issues_list.html.erb index 32a95978c25..ed6f8fe3c3a 100644 --- a/sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/issues/_issues_list.html.erb +++ b/sonar-server/src/main/webapp/WEB-INF/app/views/project/widgets/issues/_issues_list.html.erb @@ -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) -- 2.39.5