1

prepare search optimization

Co-authored-by: Christoph <tobi@urpost.de>
This commit is contained in:
Christoph
2020-03-20 16:00:07 +01:00
parent c1ce06d60f
commit 8d0c3987d2
2 changed files with 13 additions and 3 deletions

View File

@ -83,7 +83,7 @@ public class GroupService {
* @throws EventException Projektionsfehler * @throws EventException Projektionsfehler
*/ */
public List<Group> getAllGroupWithVisibilityPublic(String userId) throws EventException { public List<Group> getAllGroupWithVisibilityPublic(String userId) throws EventException {
User user = new User(userId,null, null, null); User user = new User(userId, null, null, null);
List<Event> eventsVisible = eventService.translateEventDTOs(eventRepository.findAllEventsOfGroups(eventRepository.findGroup_idsWhereVisibility(Boolean.TRUE))); List<Event> eventsVisible = eventService.translateEventDTOs(eventRepository.findAllEventsOfGroups(eventRepository.findGroup_idsWhereVisibility(Boolean.TRUE)));
List<Group> visibleGroups = projectEventList(eventsVisible); List<Group> visibleGroups = projectEventList(eventsVisible);
List<Event> eventsUser = getGroupEvents(eventRepository.findGroup_idsWhereUser_id(userId)); List<Event> eventsUser = getGroupEvents(eventRepository.findGroup_idsWhereUser_id(userId));
@ -102,7 +102,7 @@ public class GroupService {
List<Group> visibleGroups = projectEventList(eventsVisible); List<Group> visibleGroups = projectEventList(eventsVisible);
List<Group> visibleLectures = new ArrayList<>(); List<Group> visibleLectures = new ArrayList<>();
for (Group group : visibleGroups) { for (Group group : visibleGroups) {
if(group.getType() == null){ if (group.getType() == null) {
continue; continue;
} }
if (group.getType().equals(GroupType.LECTURE)) { if (group.getType().equals(GroupType.LECTURE)) {
@ -123,8 +123,10 @@ public class GroupService {
*/ */
public List<Group> findGroupWith(String search, Account account) throws EventException { public List<Group> findGroupWith(String search, Account account) throws EventException {
List<Group> groups = new ArrayList<>(); List<Group> groups = new ArrayList<>();
for (Group group : getAllGroupWithVisibilityPublic(account.getName())) { for (Group group : getAllGroupWithVisibilityPublic(account.getName())) {
if(group.getType() == null){
if (group.getType() == null) {
continue; continue;
} }
if (group.getTitle().toLowerCase().contains(search.toLowerCase()) || group.getDescription().toLowerCase().contains(search.toLowerCase())) { if (group.getTitle().toLowerCase().contains(search.toLowerCase()) || group.getDescription().toLowerCase().contains(search.toLowerCase())) {

View File

@ -0,0 +1,8 @@
package mops.gruppen2.service;
import org.springframework.stereotype.Service;
@Service
public class SearchService {
}