A self hosted chat application with end-to-end encrypted messaging.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

35 lines
1014 B

  1. package org.ros.chatto.service;
  2. import java.time.Instant;
  3. import org.ros.chatto.repository.ChatMessageRepository;
  4. import org.ros.chatto.repository.UserRepository;
  5. import org.ros.chatto.repository.UserSessionRepository;
  6. import org.springframework.stereotype.Service;
  7. import org.springframework.transaction.annotation.Transactional;
  8. import lombok.RequiredArgsConstructor;
  9. @RequiredArgsConstructor
  10. @Service
  11. @Transactional(readOnly = true)
  12. public class StatisticsService {
  13. private final ChatMessageRepository chatMessageRepository;
  14. private final UserRepository userRepo;
  15. private final UserSessionRepository userSessionRepo;
  16. public Long totalMessage() {
  17. return chatMessageRepository.totalMessages();
  18. }
  19. public Long totalUsers() {
  20. return userRepo.totalUsers();
  21. }
  22. public Long totalUsersOnline() {
  23. return userSessionRepo.totalOnlineUsers();
  24. }
  25. public Long messagesOnDay(Instant date) {
  26. return chatMessageRepository.messagesOnDate(date);
  27. }
  28. }