package es.uv.dagarcos.master.service;

import es.uv.dagarcos.master.dto.PlayerOverviewDto;
import es.uv.dagarcos.master.repository.ShardPlayerStatsRepository;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class PlayerDashboardService {

    @Autowired
    private ShardPlayerStatsRepository statsRepository;

    public List<PlayerOverviewDto> getGlobalPlayers() {

        return statsRepository.aggregateGlobalPlayerStats()
                .stream()
                .map(row -> new PlayerOverviewDto(
                        (String) row[0],
                        (Long) row[3],
                        (Long) row[1],
                        (Long) row[2]
                ))
                .toList();
    }
}

