"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.archiveDataset = void 0;
const drizzle_orm_1 = require("drizzle-orm");
const database_1 = require("../../../database");
const tables_1 = require("../../../database/tables");
const logger_1 = __importDefault(require("../../../logger"));
const archiveDataset = async (req, res) => {
    try {
        const { datasetId } = req.params;
        const db = await (0, database_1.getDb)();
        const [result] = await db
            .update(tables_1.trusysDatasetsTable)
            .set({
            is_archived: true,
            updatedAt: new Date()
        })
            .where((0, drizzle_orm_1.eq)(tables_1.trusysDatasetsTable.id, datasetId))
            .returning({
            id: tables_1.trusysDatasetsTable.id,
            is_archived: tables_1.trusysDatasetsTable.is_archived,
        });
        if (!result) {
            res.status(404).json({
                success: false,
                message: 'Dataset not found',
            });
            return;
        }
        logger_1.default.info(`Archived dataset ${datasetId}`);
        res.json({
            success: true,
            message: 'Dataset archived successfully',
            data: result,
        });
    }
    catch (error) {
        logger_1.default.error(`Error archiving dataset: ${error}`);
        res.status(500).json({
            success: false,
            message: 'Failed to archive dataset',
        });
    }
};
exports.archiveDataset = archiveDataset;
//# sourceMappingURL=archive-dataset.js.map