Fully accepted statistic
This commit is contained in:
@ -1,10 +1,12 @@
|
||||
package com.plannaplan.services;
|
||||
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import com.plannaplan.entities.Commision;
|
||||
import com.plannaplan.entities.User;
|
||||
import com.plannaplan.exceptions.UserNotFoundException;
|
||||
import com.plannaplan.models.UserApiResponse;
|
||||
@ -29,6 +31,9 @@ public class UserService {
|
||||
@Autowired
|
||||
private CommisionRepository comRepo;
|
||||
|
||||
@Autowired
|
||||
private CommisionService comService;
|
||||
|
||||
public UserService() {
|
||||
super();
|
||||
}
|
||||
@ -193,4 +198,25 @@ public class UserService {
|
||||
return this.getAllStudents().size() - this.getAmmountOfUsersWithAssignedGroups();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ammount of how many users have full schedule accepted
|
||||
*/
|
||||
public Integer getAmmountOfUsersWithAcceptedSchedules() {
|
||||
final List<User> students = this.getAllStudents();
|
||||
Integer accepted = 0;
|
||||
|
||||
final Iterator<User> it = students.iterator();
|
||||
|
||||
while (it.hasNext()) {
|
||||
final User user = it.next();
|
||||
final Optional<Commision> com = this.comService.getNewestCommision(user);
|
||||
if (com.isPresent() && user.getStudentRegisteredGrups().size() == com.get().getAssignments().size()) {
|
||||
accepted += 1;
|
||||
}
|
||||
}
|
||||
|
||||
return accepted;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user