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.

28 lines
858 B

  1. package org.ros.chatto.controller;
  2. import java.time.Instant;
  3. import org.ros.chatto.dto.StatsDTO;
  4. import org.ros.chatto.service.StatisticsService;
  5. import org.springframework.web.bind.annotation.GetMapping;
  6. import org.springframework.web.bind.annotation.RequestMapping;
  7. import org.springframework.web.bind.annotation.RestController;
  8. import lombok.RequiredArgsConstructor;
  9. @RestController
  10. @RequestMapping("/api/stats")
  11. @RequiredArgsConstructor
  12. public class StatisticsController {
  13. private final StatisticsService statisticsService;
  14. @GetMapping
  15. public StatsDTO rootStats() {
  16. return StatsDTO.builder()
  17. .totalMessages(statisticsService.totalMessage())
  18. .totalOnlineUsers(statisticsService.totalUsersOnline())
  19. .numMessagesToday(
  20. statisticsService.messagesOnDay(Instant.now()))
  21. .totalUsers(statisticsService.totalUsers()).build();
  22. }
  23. }