Fully accepted statistic

This commit is contained in:
Filip Izydorczyk
2021-01-21 16:08:53 +01:00
parent 6a0d425c37
commit 270e31f120
3 changed files with 73 additions and 0 deletions

View File

@ -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;
}
}