import { getStatus } from '../../../utils/requestStatusHelper.js';
import localsHelper from '../../../utils/localsHelper.js';

const getRequestStatus = async ({ req, res, services }) => {
    const { executionId, status: currentStatus } = req.body;
    const { dprUser } = localsHelper.getValues(res);
    const response = await 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,
};

export { AsyncRequestListUtils as default, filterReports, getRequestStatus };
//# sourceMappingURL=utils.js.map
