"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.RagChartsController = void 0;
const logger_1 = __importDefault(require("../../../logger"));
const ragChartsService_1 = require("../../services/ragChartsService");
const defaultStart = new Date(Date.now() - 7 * 24 * 60 * 60 * 1000).toISOString();
const defaultEnd = new Date().toISOString();
function toParams(req) {
    const { applicationId, start, end, orgId, projectId, mode } = req.query;
    return {
        applicationId: applicationId ?? '',
        start: start || defaultStart,
        end: end || defaultEnd,
        orgId: orgId,
        projectId: projectId,
        mode: mode,
    };
}
exports.RagChartsController = {
    async getRequestsBreakdown(req, res) {
        try {
            const params = toParams(req);
            const data = await ragChartsService_1.ragChartsService.getRequestsBreakdown(params);
            res.json({ success: true, data });
        }
        catch (error) {
            logger_1.default.error(`Error in getRequestsBreakdown: ${error}`);
            res.status(500).json({
                success: false,
                message: error.message,
            });
        }
    },
    async getRetrievalHitRate(req, res) {
        try {
            const params = toParams(req);
            const data = await ragChartsService_1.ragChartsService.getRetrievalHitRate(params);
            res.json({ success: true, data });
        }
        catch (error) {
            logger_1.default.error(`Error in getRetrievalHitRate: ${error}`);
            res.status(500).json({
                success: false,
                message: error.message,
            });
        }
    },
    async getRetrievalLatency(req, res) {
        try {
            const params = toParams(req);
            const data = await ragChartsService_1.ragChartsService.getRetrievalLatency(params);
            res.json({ success: true, data });
        }
        catch (error) {
            logger_1.default.error(`Error in getRetrievalLatency: ${error}`);
            res.status(500).json({
                success: false,
                message: error.message,
            });
        }
    },
    async getRetrievalLatencyDistribution(req, res) {
        try {
            const params = toParams(req);
            const data = await ragChartsService_1.ragChartsService.getRetrievalLatencyDistribution(params);
            res.json({ success: true, data });
        }
        catch (error) {
            logger_1.default.error(`Error in getRetrievalLatencyDistribution: ${error}`);
            res.status(500).json({
                success: false,
                message: error.message,
            });
        }
    },
    async getVectorDbThroughput(req, res) {
        try {
            const params = toParams(req);
            const data = await ragChartsService_1.ragChartsService.getVectorDbThroughput(params);
            res.json({ success: true, data });
        }
        catch (error) {
            logger_1.default.error(`Error in getVectorDbThroughput: ${error}`);
            res.status(500).json({
                success: false,
                message: error.message,
            });
        }
    },
    async getVectorDbPerformanceTrend(req, res) {
        try {
            const params = toParams(req);
            const data = await ragChartsService_1.ragChartsService.getVectorDbPerformanceTrend(params);
            res.json({ success: true, data });
        }
        catch (error) {
            logger_1.default.error(`Error in getVectorDbPerformanceTrend: ${error}`);
            res.status(500).json({
                success: false,
                message: error.message,
            });
        }
    },
    async getRequestVolumeByOperation(req, res) {
        try {
            const params = toParams(req);
            const data = await ragChartsService_1.ragChartsService.getRequestVolumeByOperation(params);
            res.json({ success: true, data });
        }
        catch (error) {
            logger_1.default.error(`Error in getRequestVolumeByOperation: ${error}`);
            res.status(500).json({
                success: false,
                message: error.message,
            });
        }
    },
    async getResponseTimeByOperation(req, res) {
        try {
            const params = toParams(req);
            const data = await ragChartsService_1.ragChartsService.getResponseTimeByOperation(params);
            res.json({ success: true, data });
        }
        catch (error) {
            logger_1.default.error(`Error in getResponseTimeByOperation: ${error}`);
            res.status(500).json({
                success: false,
                message: error.message,
            });
        }
    },
};
//# sourceMappingURL=index.js.map