"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.DeleteDataTask = void 0;
const DataDeletionSchema_1 = require("../../../shared/schema/DataDeletionSchema");
const workers_1 = require("@golemio/core/dist/integration-engine/workers");
const SelectRepositoryFactory_1 = require("../../helpers/SelectRepositoryFactory");
class DeleteDataTask extends workers_1.AbstractTask {
    constructor(queuePrefix) {
        super(queuePrefix);
        this.queueName = "deleteData";
        this.queueTtl = 15 * 60 * 1000; // 15 minutes
        this.schema = DataDeletionSchema_1.DataDeletionValidationSchema;
        this.selectRepositoryFactory = new SelectRepositoryFactory_1.SelectRepositoryFactory();
    }
    async execute(data) {
        const repository = this.selectRepositoryFactory.select(data.repoName);
        const columnName = this.selectRepositoryFactory.getColumnNameByRepositoryName(data.repoName);
        await repository.deleteNHoursOldData(data.targetHours, columnName);
    }
}
exports.DeleteDataTask = DeleteDataTask;
//# sourceMappingURL=DeleteDataTask.js.map