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.
29 lines
942 B
29 lines
942 B
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();
|
|
}
|
|
|
|
}
|