|
|
@ -0,0 +1,29 @@ |
|
|
|
package org.ros.chatto.controller; |
|
|
|
|
|
|
|
import java.time.Instant; |
|
|
|
|
|
|
|
import org.ros.chatto.dto.StatsDTO; |
|
|
|
import org.ros.chatto.service.StatisticsService; |
|
|
|
import org.springframework.web.bind.annotation.GetMapping; |
|
|
|
import org.springframework.web.bind.annotation.RequestMapping; |
|
|
|
import org.springframework.web.bind.annotation.RestController; |
|
|
|
|
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
|
|
|
|
|
@RestController |
|
|
|
@RequestMapping("/api/stats") |
|
|
|
@RequiredArgsConstructor |
|
|
|
public class StatisticsController { |
|
|
|
private final StatisticsService statisticsService; |
|
|
|
|
|
|
|
@GetMapping |
|
|
|
public StatsDTO rootStats() { |
|
|
|
return StatsDTO.builder() |
|
|
|
.totalMessages(statisticsService.totalMessage()) |
|
|
|
.totalOnlineUsers(statisticsService.totalUsersOnline()) |
|
|
|
.numMessagesToday( |
|
|
|
statisticsService.messagesOnDay(Instant.now())) |
|
|
|
.totalUsers(statisticsService.totalUsers()).build(); |
|
|
|
} |
|
|
|
|
|
|
|
} |