use of org.hisp.dhis.datasummary.DataSummary in project dhis2-core by dhis2.
the class DefaultDataStatisticsService method getSystemStatisticsSummary.
@Override
public DataSummary getSystemStatisticsSummary() {
DataSummary statistics = new DataSummary();
// Database objects
Map<String, Long> objectCounts = new HashMap<>();
statisticsProvider.getObjectCounts().forEach((object, count) -> objectCounts.put(object.getValue(), count));
statistics.setObjectCounts(objectCounts);
// Active users
Date lastHour = new DateTime().minusHours(1).toDate();
Map<Integer, Integer> activeUsers = new HashMap<>();
activeUsers.put(0, userService.getActiveUsersCount(lastHour));
activeUsers.put(1, userService.getActiveUsersCount(0));
activeUsers.put(2, userService.getActiveUsersCount(1));
activeUsers.put(7, userService.getActiveUsersCount(7));
activeUsers.put(30, userService.getActiveUsersCount(30));
statistics.setActiveUsers(activeUsers);
// User invitations
Map<String, Integer> userInvitations = new HashMap<>();
UserQueryParams inviteAll = new UserQueryParams();
inviteAll.setInvitationStatus(UserInvitationStatus.ALL);
userInvitations.put(UserInvitationStatus.ALL.getValue(), userService.getUserCount(inviteAll));
UserQueryParams inviteExpired = new UserQueryParams();
inviteExpired.setInvitationStatus(UserInvitationStatus.EXPIRED);
userInvitations.put(UserInvitationStatus.EXPIRED.getValue(), userService.getUserCount(inviteExpired));
statistics.setUserInvitations(userInvitations);
// Data values
Map<Integer, Integer> dataValueCount = new HashMap<>();
dataValueCount.put(0, dataValueService.getDataValueCount(0));
dataValueCount.put(1, dataValueService.getDataValueCount(1));
dataValueCount.put(7, dataValueService.getDataValueCount(7));
dataValueCount.put(30, dataValueService.getDataValueCount(30));
statistics.setDataValueCount(dataValueCount);
// Events
Map<Integer, Long> eventCount = new HashMap<>();
eventCount.put(0, programStageInstanceService.getProgramStageInstanceCount(0));
eventCount.put(1, programStageInstanceService.getProgramStageInstanceCount(1));
eventCount.put(7, programStageInstanceService.getProgramStageInstanceCount(7));
eventCount.put(30, programStageInstanceService.getProgramStageInstanceCount(30));
statistics.setEventCount(eventCount);
return statistics;
}
Aggregations