mailtrain/server/lib/report-helpers.js
Tomas Bures 66702b5edc Fixes in reports (generating a CSV).
Added caching of generated images in mosaico handler.
Various other fixes.
2019-04-22 02:41:40 +02:00

34 lines
728 B
JavaScript

'use strict';
const path = require('path');
function nameToFileName(name) {
return name.
trim().
toLowerCase().
replace(/[ .+/]/g, '-').
replace(/[^a-z0-9\-_]/gi, '').
replace(/--*/g, '-');
}
const reportFilesDir = path.join(__dirname, '..', 'files', 'reports');
function getReportFileBase(report) {
return path.join(reportFilesDir, report.id + '-' + nameToFileName(report.name));
}
function getReportContentFile(report) {
return getReportFileBase(report) + '.out';
}
function getReportOutputFile(report) {
return getReportFileBase(report) + '.err';
}
module.exports = {
getReportContentFile,
getReportOutputFile,
nameToFileName,
reportFilesDir
};