Commit c3837704 authored by oleg.pahhomov's avatar oleg.pahhomov

SA0140-537 | do not display duplicate widgets

parent f1210959
......@@ -8,7 +8,7 @@ import java.util.Optional;
public interface UserWidgetRepository extends JpaRepository<UserWidget, Long> {
List<UserWidget> findAllByAppUserAndDashboardAndSelectedOrderByOrderNrAsc(Long user, Long dashboard, boolean selected);
List<UserWidget> findDistinctByAppUserAndDashboardAndSelectedOrderByOrderNrAsc(Long user, Long dashboard, boolean selected);
List<UserWidget> findAllByDashboard(Long dashboard);
......
......@@ -56,7 +56,7 @@ public class WidgetCustomRepositoryImpl implements WidgetCustomRepository {
@Override
public List<Widget> findWidgetByMyDashboard(Long dashboard) {
return entityManager.createNativeQuery("" +
"SELECT w.* from widget w\n" +
"SELECT distinct w.* from widget w\n" +
"join dashboard_widget dw on w.id = dw.widget\n" +
"where dw.dashboard = :dashboard \n", Widget.class)
.setParameter("dashboard", dashboard)
......
......@@ -17,7 +17,7 @@ public class UserWidgetService {
private UserWidgetRepository userWidgetRepository;
public List<Long> getSelectedWidgets(Dashboard dashboard, StatUser user) {
return userWidgetRepository.findAllByAppUserAndDashboardAndSelectedOrderByOrderNrAsc(user.getId(), dashboard.getId(), true)
return userWidgetRepository.findDistinctByAppUserAndDashboardAndSelectedOrderByOrderNrAsc(user.getId(), dashboard.getId(), true)
.stream()
.map(UserWidget::getWidget)
.collect(Collectors.toList());
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment