Students registered satistics
This commit is contained in:
@ -10,17 +10,15 @@ import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.stereotype.Repository;
|
||||
|
||||
/**
|
||||
* CommisionRepository.getUsers:
|
||||
* Return list of:
|
||||
* SELECT * FROM Commision WHERE owner_id = i .
|
||||
* CommisionRepository.getUsers: Return list of: SELECT * FROM Commision WHERE
|
||||
* owner_id = i .
|
||||
*
|
||||
* Where i, ?1 are equale to variables.
|
||||
* Where i, ?1 are equale to variables.
|
||||
*
|
||||
* CommisionRepository.getNewestCommision
|
||||
* Return list of:
|
||||
* SELECT * FROM Commision WHERE owner_id = i Order by commisionDate desc.
|
||||
* CommisionRepository.getNewestCommision Return list of: SELECT * FROM
|
||||
* Commision WHERE owner_id = i Order by commisionDate desc.
|
||||
*
|
||||
* Where i, ?1 are equale to variables.
|
||||
* Where i, ?1 are equale to variables.
|
||||
*/
|
||||
@Repository
|
||||
public interface CommisionRepository extends JpaRepository<Commision, Long> {
|
||||
@ -30,4 +28,10 @@ public interface CommisionRepository extends JpaRepository<Commision, Long> {
|
||||
@Query("FROM Commision WHERE owner_id = ?1 order by commisionDate desc")
|
||||
List<Commision> getNewestCommision(@Param("owner_id") Long id);
|
||||
|
||||
/**
|
||||
* @return ammount of uniqe users that have a commision placed on first array
|
||||
* element
|
||||
*/
|
||||
@Query("SELECT COUNT(DISTINCT owner_id) AS count FROM Commision")
|
||||
Object[] getUsersAssigned();
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import java.util.stream.Collectors;
|
||||
import com.plannaplan.entities.User;
|
||||
import com.plannaplan.exceptions.UserNotFoundException;
|
||||
import com.plannaplan.models.UserApiResponse;
|
||||
import com.plannaplan.repositories.CommisionRepository;
|
||||
import com.plannaplan.repositories.UserRepository;
|
||||
import com.plannaplan.types.UserRoles;
|
||||
|
||||
@ -25,6 +26,9 @@ public class UserService {
|
||||
@Autowired
|
||||
private UsosApiService service;
|
||||
|
||||
@Autowired
|
||||
private CommisionRepository comRepo;
|
||||
|
||||
public UserService() {
|
||||
super();
|
||||
}
|
||||
@ -169,4 +173,17 @@ public class UserService {
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @return ammount of how many users created an assignment
|
||||
*/
|
||||
public int getAmmountOfUsersWithAssignedGroups() {
|
||||
int response = 0;
|
||||
|
||||
final Object dbResponse = this.comRepo.getUsersAssigned()[0];
|
||||
if (dbResponse != null) {
|
||||
response = ((Long) dbResponse).intValue();
|
||||
}
|
||||
return response;
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user