package org.ros.chatto.service;

import java.time.Instant;

import org.ros.chatto.repository.ChatMessageRepository;
import org.ros.chatto.repository.UserRepository;
import org.ros.chatto.repository.UserSessionRepository;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import lombok.RequiredArgsConstructor;

@RequiredArgsConstructor
@Service
@Transactional(readOnly = true)
public class StatisticsService {
    private final ChatMessageRepository chatMessageRepository;
    private final UserRepository userRepo;
    private final UserSessionRepository userSessionRepo;

    public Long totalMessage() {
        return chatMessageRepository.totalMessages();
    }

    public Long totalUsers() {
        return userRepo.totalUsers();
    }

    public Long totalUsersOnline() {
        return userSessionRepo.totalOnlineUsers();
    }

    public Long messagesOnDay(Instant date) {
        return chatMessageRepository.messagesOnDate(date);
    }
}