package com.infoclinika.pdx.controller;

import com.infoclinika.pdx.service.statistics.GeneralStatisticsService;
import com.infoclinika.pdx.service.statistics.PortalStatistics;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * Handles requests to get general statistics.
 */
@RestController
@RequestMapping("/api/statistics")
public class GeneralStatisticsController {
    private final Logger logger = LoggerFactory.getLogger(this.getClass());
    private final GeneralStatisticsService generalStatisticsService;

    /**
     * Constructor to provide required services.
     */
    @Autowired
    public GeneralStatisticsController(GeneralStatisticsService service) {
        this.generalStatisticsService = service;
    }

    /**
     * Returns general portal statistics.
     */
    @GetMapping("/general")
    public PortalStatistics getPortalStatistics() {
        logger.debug("Request to /api/statistics/general");
        return generalStatisticsService.getPortalStatistics();
    }
}
