tango-app-api-infra 3.0.42-dev → 3.0.43-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tango-app-api-infra",
3
- "version": "3.0.42-dev",
3
+ "version": "3.0.43-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -604,28 +604,32 @@ export async function infraReportSent( req, res ) {
604
604
  } ) );
605
605
  }
606
606
  let reportdate = dayjs().format( 'YYYY-MM-DD' );
607
- const wb = new xl.Workbook();
608
- const ws = wb.addWorksheet( 'Daily report' );
609
- const headers = Object.keys( exportdata[0] );
610
-
611
- for ( let i = 0; i < headers.length; i++ ) {
612
- ws.cell( 1, i + 1 ).string( headers[i] );
613
- };
614
- for ( let i = 0; i < exportdata.length; i++ ) {
615
- const dataRow = exportdata[i];
616
- for ( let j = 0; j < headers.length; j++ ) {
617
- const header = headers[j];
618
- const value = dataRow[header];
619
- ws.cell( i + 2, j + 1 ).string( value?.toString() );
607
+ let attachments= null;
608
+ if ( exportdata.length>0 ) {
609
+ const wb = new xl.Workbook();
610
+ const ws = wb.addWorksheet( 'Daily report' );
611
+ const headers = Object.keys( exportdata[0] );
612
+
613
+ for ( let i = 0; i < headers.length; i++ ) {
614
+ ws.cell( 1, i + 1 ).string( headers[i] );
615
+ };
616
+ for ( let i = 0; i < exportdata.length; i++ ) {
617
+ const dataRow = exportdata[i];
618
+ for ( let j = 0; j < headers.length; j++ ) {
619
+ const header = headers[j];
620
+ const value = dataRow[header];
621
+ ws.cell( i + 2, j + 1 ).string( value?.toString() );
622
+ }
620
623
  }
624
+ let buffer = await wb.writeToBuffer();
625
+
626
+ attachments = {
627
+ filename: `dailyInfraReport- ${reportdate}.xlsx`,
628
+ content: buffer,
629
+ contentType: 'application/xlsx', // e.g., 'application/pdf'
630
+ };
621
631
  }
622
- let buffer = await wb.writeToBuffer();
623
632
 
624
- const attachments = {
625
- filename: `dailyInfraReport- ${reportdate}.xlsx`,
626
- content: buffer,
627
- contentType: 'application/xlsx', // e.g., 'application/pdf'
628
- };
629
633
  const subject = `Daily Digest - Infra Downtime Report - ${reportdate}`;
630
634
  const fileContent = readFileSync( join() + '/src/hbs/dailyInfraReport.hbs', 'utf8' );
631
635
  const htmlContent = handlebars.compile( fileContent );