'use strict';

var UserReports = require('../../../types/UserReports.js');
var localsHelper = require('../../../utils/localsHelper.js');

const cancelRequest = async ({ req, res, services }) => {
    const { token, dprUser, definitionsPath } = localsHelper.default.getValues(res);
    const { reportId, id, executionId, type } = req.params;
    let service = services.reportingService;
    if (type === UserReports.ReportType.REPORT)
        service = services.reportingService;
    if (type === UserReports.ReportType.DASHBOARD)
        service = services.dashboardService;
    const response = await service.cancelAsyncRequest(token, reportId, id, executionId, definitionsPath);
    if (response && response['cancellationSucceeded']) {
        await services.requestedReportService.updateStatus(executionId, dprUser.id, UserReports.RequestStatus.ABORTED);
    }
};

exports.cancelRequest = cancelRequest;
//# sourceMappingURL=utils.js.map
