package com.ikon.projectmanagement.service.impl;

import java.util.List;

import org.springframework.stereotype.Service;

import com.ikon.projectmanagement.dto.response.DashboardWidgetsResponseDto;
import com.ikon.projectmanagement.dto.response.StatusWiseProjectResponseData;
import com.ikon.projectmanagement.repository.IssueRepository;
import com.ikon.projectmanagement.repository.ProjectRepository;
import com.ikon.projectmanagement.repository.RiskRepository;
import com.ikon.projectmanagement.service.DashboardService;
import lombok.RequiredArgsConstructor;

@Service
@RequiredArgsConstructor
public class DashboardServiceImpl implements DashboardService {
    private final ProjectRepository projectRepository;
    private final IssueRepository issueRepository;
    private final RiskRepository riskRepository;

    @Override
    public DashboardWidgetsResponseDto getDashboardWidgetsData() {
        DashboardWidgetsResponseDto widgetsData = new DashboardWidgetsResponseDto();
        widgetsData.setTotalProjects(projectRepository.count());
        widgetsData.setTotalIssues(issueRepository.count());
        widgetsData.setTotalRisksCount(riskRepository.count());
        return widgetsData;
    }

    @Override
    public List<StatusWiseProjectResponseData> getStatusWiseProjectData() {
        return projectRepository.getProjectStatusCounts();
    }
}
