"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getScheduleJobsList = void 0;
const logger_1 = __importDefault(require("../../../logger"));
const scheduleJobsService_1 = require("../../services/scheduleJobsService");
const getScheduleJobsList = async (req, res) => {
    try {
        const { projectId, orgId, page = 1, limit = 10, search, status, type, archived_data_required = 'true', } = req.query;
        if (!projectId) {
            res.status(400).json({
                success: false,
                message: 'Missing required parameter: projectId',
            });
            return;
        }
        const result = await scheduleJobsService_1.scheduleJobsService.getScheduleJobsList({
            projectId: projectId,
            workspaceId: orgId,
            page: Number(page),
            limit: Number(limit),
            search: search,
            status: status ? Number(status) : undefined,
            type: type ? Number(type) : undefined,
            archived_data_required: archived_data_required === 'true',
        });
        res.json({
            success: true,
            data: result.data,
            pagination: result.pagination,
        });
    }
    catch (error) {
        logger_1.default.error(`Error fetching schedule jobs list: ${error}`);
        res.status(500).json({
            success: false,
            message: 'Failed to fetch schedule jobs list',
            error: error.message,
        });
    }
};
exports.getScheduleJobsList = getScheduleJobsList;
//# sourceMappingURL=get-schedule-jobs-list.js.map