package es.uv.dagarcos.master.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import es.uv.dagarcos.master.dto.RankingEntryDto;
import es.uv.dagarcos.master.service.RankingDashboardService;

@RestController
@RequestMapping("/master/rankings")
@CrossOrigin
public class DashboardRankingController {

    @Autowired
    private RankingDashboardService rankingService;

    @GetMapping("/global")
    public List<RankingEntryDto> globalRanking() {
        return rankingService.getGlobalRanking();
    }

    @GetMapping("/shards/{shardId}")
    public List<RankingEntryDto> shardRanking(
            @PathVariable String shardId) {
        return rankingService.getShardRanking(shardId);
    }
}
