Skip to content

Commit

Permalink
feat: SJIP-569 code review fix
Browse files Browse the repository at this point in the history
  • Loading branch information
celinepelletier committed Oct 17, 2023
1 parent e7dad13 commit 47fa750
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/reports/biospecimen-request/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,13 @@ const biospecimenRequest = async (req: Request, res: Response, _next: NextFuncti
const normalizedConfigs: ExtendedReportConfigs = await normalizeConfigs(esClient, projectId, config);

const nowUTC = getUTCDate();
const filenameZip = `include_biospecimenRequest_${format(nowUTC, "yyyyMMdd'T'HHmmss'Z'")}.zip`;
const filenameZip = generateFileName('zip', nowUTC, '');
const pathFileZip = `/tmp/${filenameZip}`;

const filenameXlsx = `include_biospecimenRequest_${format(nowUTC, "yyyyMMdd'T'HHmmss'Z'")}.xlsx`;
const filenameXlsx = generateFileName('xlsx', nowUTC, '');
const pathFileXlsx = `/tmp/${filenameXlsx}`;

const filenameTxt = `include_biospecimenRequest_README_${format(nowUTC, "yyyyMMdd'T'HHmmss'Z'")}.txt`;
const filenameTxt = generateFileName('txt', nowUTC, 'README_');
const pathFileTxt = `/tmp/${filenameTxt}`;

// Generate the files
Expand Down Expand Up @@ -73,4 +73,7 @@ const biospecimenRequest = async (req: Request, res: Response, _next: NextFuncti
}
};

const generateFileName = (ext: string, nowUTC: Date, suffix: string) =>
`include_biospecimenRequest_${suffix}${format(nowUTC, "yyyyMMdd'T'HHmmss'Z'")}.${ext}`;

export default biospecimenRequest;

0 comments on commit 47fa750

Please sign in to comment.