'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

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

const getRequestStatus = async ({ req, res, services }) => {
    const { executionId, status: currentStatus } = req.body;
    const { dprUser } = localsHelper.default.getValues(res);
    const response = await requestStatusHelper.getStatus({ req, res, services });
    const errorMessage = response.errorMessage ? JSON.stringify(response.errorMessage) : undefined;
    if (currentStatus !== response.status) {
        await services.requestedReportService.updateStatus(executionId, dprUser.id, response.status, errorMessage);
        response.reportData = await services.requestedReportService.getReportByExecutionId(executionId, dprUser.id);
    }
    return response;
};
const filterReports = (report) => {
    return report.timestamp ? !report.timestamp.lastViewed : false;
};
var AsyncRequestListUtils = {
    getRequestStatus,
    filterReports,
};

exports.default = AsyncRequestListUtils;
exports.filterReports = filterReports;
exports.getRequestStatus = getRequestStatus;
//# sourceMappingURL=utils.js.map
