Added getting sorted students
This commit is contained in:
@ -3,6 +3,7 @@ package com.plannaplan.services;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.plannaplan.entities.User;
|
||||
import com.plannaplan.exceptions.UserNotFoundException;
|
||||
@ -153,4 +154,15 @@ public class UserService {
|
||||
return this.repo.getAllByRole(UserRoles.ADMIN).size() > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* get students sorted by their ranking
|
||||
*
|
||||
* @return list of students
|
||||
*/
|
||||
public List<User> getStudentsSortedByRanking() {
|
||||
return this.repo.getAllByRole(UserRoles.STUDENT).stream().sorted((u1, u2) -> {
|
||||
return -1 * u1.getRanking().compareTo(u2.getRanking());
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user