tango-app-api-infra 3.0.102-dev → 3.0.104-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.102-dev",
3
+ "version": "3.0.104-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "nodemon": "^3.1.0",
28
28
  "swagger-ui-express": "^5.0.0",
29
29
  "tango-api-schema": "^2.0.115",
30
- "tango-app-api-middleware": "^1.0.73-test",
30
+ "tango-app-api-middleware": "^3.1.19",
31
31
  "winston": "^3.12.0",
32
32
  "winston-daily-rotate-file": "^5.0.0"
33
33
  },
@@ -573,9 +573,7 @@ export async function InstallationIssuesTable( req, res ) {
573
573
  if ( req.body.installtionfilterIssue == 'installFailedStores' ) {
574
574
  query.push( { $match: { 'ticketDetails.issueStatus': 'identified' } } );
575
575
  }
576
- if ( req.body.installtionfilterIssue == 'installedStores' ) {
577
- query.push( { $match: { 'ticketDetails.issueStatus': 'notidentified' } } );
578
- }
576
+
579
577
  query.push( {
580
578
  $project: {
581
579
  createdAt: 1,
@@ -867,7 +865,7 @@ export async function livecountCheck( data, inputData ) {
867
865
  for ( const obj of TimeSlots ) {
868
866
  obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
869
867
  obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
870
- const liveCount = await getOpenSearchData( 'data_not_received_hour',
868
+ const liveCount = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).dataNotReceivedHour,
871
869
  {
872
870
  'size': 1,
873
871
  'query': {
@@ -1154,7 +1152,7 @@ function downStoresCheck( data, inputData ) {
1154
1152
  for ( const obj of TimeSlots ) {
1155
1153
  obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
1156
1154
  obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
1157
- const downTime = await getOpenSearchData( 'live_downtime_hourly_test1',
1155
+ const downTime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly,
1158
1156
  {
1159
1157
  'size': 1,
1160
1158
  'query': {
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { findOneTangoTicket, createTangoTicket, updateOneTangoTicket, aggregateTangoTicket, countDocumentsTangoTicket } from '../services/tangoTicket.service.js';
3
- import { logger, getUTC, appConfig, fileUpload, signedUrl, sendMessageToQueue, listFileByPath } from 'tango-app-api-middleware';
3
+ import { logger, getUTC, fileUpload, signedUrl, sendMessageToQueue, listFileByPath } from 'tango-app-api-middleware';
4
4
  import dayjs from 'dayjs';
5
5
 
6
6
  export async function createTicket( req, res ) {
@@ -12,14 +12,14 @@ export async function createTicket( req, res ) {
12
12
  }
13
13
 
14
14
  let param = {
15
- Bucket: appConfig.cloud.aws.bucket.auditInput,
15
+ Bucket: JSON.parse( process.env.BUCKET ).auditInput,
16
16
  file_path: `${dayjs( new Date( req.body.Date ) ).format( 'DD-MM-YYYY' )}/${req.body.storeId}/`,
17
17
  MaxKeys: 1,
18
18
  };
19
19
 
20
20
  const auditInputData = await listFileByPath( param );
21
21
 
22
- param.Bucket = appConfig.cloud.aws.bucket.auditOutput;
22
+ param.Bucket = JSON.parse( process.env.BUCKET ).auditOutput;
23
23
 
24
24
  param.file_path = `${req.body.storeId}/${dayjs( new Date( req.body.Date ) ).format( 'DD-MM-YYYY' )}/`;
25
25
 
@@ -27,7 +27,7 @@ export async function createTicket( req, res ) {
27
27
 
28
28
 
29
29
  if ( req.body.issueType === 'highcount' ) {
30
- param.Bucket = appConfig.cloud.aws.bucket.edgeAppSource;
30
+ param.Bucket = JSON.parse( process.env.BUCKET ).edgeAppSource;
31
31
 
32
32
  const edgeAppSource = await listFileByPath( param );
33
33
 
@@ -56,7 +56,7 @@ export async function createTicket( req, res ) {
56
56
  let getObject = {};
57
57
  if ( req.files ) {
58
58
  let params = {
59
- Bucket: appConfig.cloud.aws.bucket.ticket,
59
+ Bucket: JSON.parse( process.env.BUCKET ).ticket,
60
60
  Key: create.ticketId + '/',
61
61
  ContentType: 'multipart/form-data',
62
62
  body: req.files.img.data,
@@ -88,7 +88,7 @@ export async function createTicket( req, res ) {
88
88
  };
89
89
 
90
90
  if ( req.body.issueType === 'highcount' ) {
91
- await sendMessageToQueue( `${appConfig.cloud.aws.sqs.url}${appConfig.cloud.aws.sqs.highcountTopic}`, JSON.stringify( obj ) );
91
+ await sendMessageToQueue( `${JSON.parse( process.env.SQS ).url}${JSON.parse( process.env.SQS ).highcountTopic}`, JSON.stringify( obj ) );
92
92
  }
93
93
  if ( create ) {
94
94
  res.sendSuccess( 'Ticket Created Successfully' );
@@ -268,7 +268,7 @@ export async function showActivity( req, res ) {
268
268
  if ( activity.attachments&&activity.attachments.length>0 ) {
269
269
  for ( let attchment of activity.attachments ) {
270
270
  let params = {
271
- Bucket: appConfig.cloud.aws.bucket.ticket,
271
+ Bucket: JSON.parse( process.env.BUCKET ).ticket,
272
272
  file_path: attchment.filePath,
273
273
  };
274
274
  let attachments = await signedUrl( params );
@@ -3,7 +3,7 @@
3
3
  import { aggregateTangoTicket, createTangoTicket, findOneTangoTicket, updateOneTangoTicket, updateManyTangoTicket, findTangoTicket } from '../services/tangoTicket.service.js';
4
4
  import { createinfraReason, findinfraReason } from '../services/infraReason.service.js';
5
5
  import { updateOneStore, findStore } from '../services/store.service.js';
6
- import { logger, fileUpload, signedUrl, chunkArray, sendEmailWithSES, getOpenSearchData, insertOpenSearchData, download, appConfig, getUTC } from 'tango-app-api-middleware';
6
+ import { logger, fileUpload, signedUrl, chunkArray, sendEmailWithSES, getOpenSearchData, insertOpenSearchData, download, getUTC } from 'tango-app-api-middleware';
7
7
  import { aggregateUser, updateOneUser } from '../services/user.service.js';
8
8
  import { findOneClient, updateoneClient } from '../services/client.service.js';
9
9
  import dayjs from 'dayjs';
@@ -58,7 +58,7 @@ export async function createTicket( req, res ) {
58
58
  },
59
59
  };
60
60
  let downtimetotal;
61
- const downtime = await getOpenSearchData( 'live_downtime_hourly_test1', downTimeQuery );
61
+ const downtime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery );
62
62
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
63
63
  if ( streamwiseDowntime.length > 0 ) {
64
64
  const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
@@ -77,11 +77,11 @@ export async function createTicket( req, res ) {
77
77
  const subject = `Tango Eye - Ticket Created for ${req.body.basicDetails.storeName}`;
78
78
  const fileContent = readFileSync( join() + '/src/hbs/createTicket.hbs', 'utf8' );
79
79
  const htmlContent = handlebars.compile( fileContent );
80
- let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${req.body.basicDetails.storeId}`;
80
+ let Uidomain = `${JSON.parse( process.env.URL ).domain}/manage/stores/infra-ticket?storeId=${req.body.basicDetails.storeId}`;
81
81
 
82
- const html = htmlContent( { ...req.body, Uidomain: Uidomain, domain: appConfig.url.apiDomain, date: dayjs( req.body.issueDate ).format( 'YYYY-MM-DD' ), downtimetotal: downtimetotal, Timestamp: Timestamp } );
82
+ const html = htmlContent( { ...req.body, Uidomain: Uidomain, domain: JSON.parse( process.env.URL ).apiDomain, date: dayjs( req.body.issueDate ).format( 'YYYY-MM-DD' ), downtimetotal: downtimetotal, Timestamp: Timestamp } );
83
83
  if ( req.body.emailAlert && req.body.spocEmail && req.body.issueType == 'infra' && isValidEmail( req.body.spocEmail ) ) {
84
- await sendEmailWithSES( req.body.spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
84
+ await sendEmailWithSES( req.body.spocEmail, subject, html, attachments, JSON.parse( process.env.SES ).adminEmail );
85
85
  }
86
86
  if ( create ) {
87
87
  res.sendSuccess( 'Ticket Created Successfully' );
@@ -203,6 +203,8 @@ export async function secondaryReason( req, res ) {
203
203
  count: list.length,
204
204
  result: list,
205
205
  } );
206
+ } else {
207
+ res.sendError( 'No data found', 204 );
206
208
  }
207
209
  } catch ( error ) {
208
210
  logger.error( { error: error, function: 'secondaryReason' } );
@@ -292,7 +294,7 @@ export async function viewTicket( req, res ) {
292
294
  if ( ticket.attachments.hasOwnProperty( index ) ) {
293
295
  let file = ticket.attachments[index];
294
296
  let params = {
295
- Bucket: appConfig.cloud.aws.bucket.ticket,
297
+ Bucket: JSON.parse( process.env.BUCKET ).ticket,
296
298
  file_path: file.filePath,
297
299
  };
298
300
  let attachments = await signedUrl( params );
@@ -355,7 +357,7 @@ export async function uploadAttachments( req, res ) {
355
357
  for ( let singleImg in req.files.img ) {
356
358
  if ( req.files.img.hasOwnProperty( singleImg ) ) {
357
359
  let params = {
358
- Bucket: appConfig.cloud.aws.bucket.ticket,
360
+ Bucket: JSON.parse( process.env.BUCKET ).ticket,
359
361
  Key: req.params.ticketId + '/',
360
362
  ContentType: 'multipart/form-data',
361
363
  body: req.files.img[singleImg].data,
@@ -379,7 +381,7 @@ export async function uploadAttachments( req, res ) {
379
381
  let oldticket = await findOneTangoTicket( { ticketId: req.params.ticketId } );
380
382
  let attachments = oldticket.attachments;
381
383
  let params = {
382
- Bucket: appConfig.cloud.aws.bucket.ticket,
384
+ Bucket: JSON.parse( process.env.BUCKET ).ticket,
383
385
  Key: req.params.ticketId + '/',
384
386
  ContentType: 'multipart/form-data',
385
387
  body: req.files.img.data,
@@ -555,7 +557,7 @@ export async function saveInfraEmailConfig( req, res ) {
555
557
  },
556
558
  };
557
559
 
558
- await insertOpenSearchData( appConfig.opensearch.activityLog, logObj );
560
+ await insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
559
561
 
560
562
 
561
563
  res.sendSuccess( 'Updated Successfully' );
@@ -759,7 +761,7 @@ export async function getInfraIssues( req, res ) {
759
761
  return res.sendError( 'NO Data Found', 204 );
760
762
  }
761
763
  for ( let i =0; i< mergeValue.length; i++ ) {
762
- const downTime = await getOpenSearchData( 'live_downtime_hourly_test1',
764
+ const downTime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly,
763
765
  {
764
766
  'size': 100,
765
767
  'query': {
@@ -783,7 +785,7 @@ export async function getInfraIssues( req, res ) {
783
785
 
784
786
  } );
785
787
 
786
- const speedTest = await getOpenSearchData( 'edgeapp_systemlogs',
788
+ const speedTest = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs,
787
789
  {
788
790
  'size': 1,
789
791
  'query': {
@@ -896,7 +898,7 @@ export async function getInfraIssues( req, res ) {
896
898
  const camera = await aggregateCamera( camQuery );
897
899
  for ( let index = 0; index < camera.length; index++ ) {
898
900
  if ( camera?.[index]?.thumbnailImage ) {
899
- camera[index].thumbnailImage = await signedUrl( { Bucket: appConfig.cloud.aws.bucket.baseImage, file_path: camera[index].thumbnailImage } );
901
+ camera[index].thumbnailImage = await signedUrl( { Bucket: JSON.parse( process.env.BUCKET ).baseImage, file_path: camera[index].thumbnailImage } );
900
902
  }
901
903
  }
902
904
  logger.info( { message: camera } );
@@ -1,5 +1,5 @@
1
1
 
2
- import { logger, getOpenSearchData, appConfig } from 'tango-app-api-middleware';
2
+ import { logger, getOpenSearchData } from 'tango-app-api-middleware';
3
3
  import dayjs from 'dayjs';
4
4
  import utc from 'dayjs/plugin/utc.js';
5
5
  import timezone from 'dayjs/plugin/timezone.js';
@@ -180,7 +180,7 @@ export async function updateRefreshTicket( req, res ) {
180
180
  },
181
181
  };
182
182
  let downtimetotal;
183
- const downtime = await getOpenSearchData( 'live_downtime_hourly_test1', downTimeQuery );
183
+ const downtime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery );
184
184
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
185
185
  if ( streamwiseDowntime.length > 0 ) {
186
186
  const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
@@ -205,11 +205,11 @@ export async function updateRefreshTicket( req, res ) {
205
205
  if ( Issue.length > 0 && Issue[0].reasons.length > 0 ) {
206
206
  primaryIssue = Issue[0].reasons[0].primaryIssue;
207
207
  }
208
- let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
208
+ let Uidomain = `${JSON.parse( process.env.URL ).domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
209
209
  let getclient = await findOneClient( { clientId: getTicket.basicDetails.clientId } );
210
- const html = htmlContent( { ...getTicket, Uidomain: Uidomain, primary: primaryIssue, storeName: getTicket.basicDetails.storeName, hibernation: '', spocName: spocName, date: dayjs( getTicket.issueDate ).format( 'YYYY-MM-DD' ), downtimetotal: downtimetotal, Timestamp: Timestamp, domain: appConfig.url.apiDomain } );
210
+ const html = htmlContent( { ...getTicket, Uidomain: Uidomain, primary: primaryIssue, storeName: getTicket.basicDetails.storeName, hibernation: '', spocName: spocName, date: dayjs( getTicket.issueDate ).format( 'YYYY-MM-DD' ), downtimetotal: downtimetotal, Timestamp: Timestamp, domain: JSON.parse( process.env.URL ).apiDomain } );
211
211
  if ( getclient.ticketConfigs.emailAlert && spocEmail && isValidEmail( spocEmail ) ) {
212
- await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
212
+ await sendEmailWithSES( spocEmail, subject, html, attachments, JSON.parse( process.env.SES ).adminEmail );
213
213
  }
214
214
  }
215
215
  }
@@ -261,7 +261,7 @@ export async function closeTicket( req, res ) {
261
261
  },
262
262
  };
263
263
  let downtimetotal;
264
- const downtime = await getOpenSearchData( 'live_downtime_hourly_test1', downTimeQuery );
264
+ const downtime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery );
265
265
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
266
266
  if ( streamwiseDowntime.length > 0 ) {
267
267
  const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
@@ -288,11 +288,11 @@ export async function closeTicket( req, res ) {
288
288
  if ( store.spocDetails && store.spocDetails.length > 0 ) {
289
289
  let spocEmail = store.spocDetails[0].email;
290
290
  let spocName = store.spocDetails[0].name;
291
- let Uidomain = `${appConfig.url.domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
291
+ let Uidomain = `${JSON.parse( process.env.URL ).domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
292
292
  let getclient = await findOneClient( { clientId: getTicket.basicDetails.clientId } );
293
- const html = htmlContent( { ...getTicket, Uidomain: Uidomain, primaryIssue: primaryIssue, storeName: getTicket.basicDetails.storeName, spocName: spocName, date: dayjs( getTicket.issueDate ).format( 'YYYY-MM-DD HH:mm' ), downtimetotal: downtimetotal, Timestamp: Timestamp, domain: appConfig.url.apiDomain } );
293
+ const html = htmlContent( { ...getTicket, Uidomain: Uidomain, primaryIssue: primaryIssue, storeName: getTicket.basicDetails.storeName, spocName: spocName, date: dayjs( getTicket.issueDate ).format( 'YYYY-MM-DD HH:mm' ), downtimetotal: downtimetotal, Timestamp: Timestamp, domain: JSON.parse( process.env.URL ).apiDomain } );
294
294
  if ( getclient.ticketConfigs.emailAlert && spocEmail && isValidEmail( spocEmail ) ) {
295
- await sendEmailWithSES( spocEmail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
295
+ await sendEmailWithSES( spocEmail, subject, html, attachments, JSON.parse( process.env.SES ).adminEmail );
296
296
  }
297
297
  }
298
298
  }
@@ -559,7 +559,7 @@ export async function infraReportSent( req, res ) {
559
559
  'Latest Comment': element.otherscomment ? element.otherscomment : element.commentText,
560
560
  'Activity Log': {
561
561
  label: 'Link',
562
- url: `${appConfig.url.domain + '/manage/stores/infra-ticket?storeId=' + element.basicDetails.storeId}`,
562
+ url: `${JSON.parse( process.env.URL ).domain + '/manage/stores/infra-ticket?storeId=' + element.basicDetails.storeId}`,
563
563
  },
564
564
  } );
565
565
  }
@@ -608,12 +608,12 @@ export async function infraReportSent( req, res ) {
608
608
  const subject = `Daily Digest - Infra Downtime Report - ${date}`;
609
609
  const fileContent = readFileSync( join() + '/src/hbs/dailyInfraReport.hbs', 'utf8' );
610
610
  const htmlContent = handlebars.compile( fileContent );
611
- let Uidomain = `${appConfig.url.domain}`;
611
+ let Uidomain = `${JSON.parse( process.env.URL ).domain}`;
612
612
 
613
613
 
614
- const html = htmlContent( { ...req.body, Uidomain: Uidomain, issueCount: issueCount, avgDownTime: avgDownTime, reportdate: date, content: response, date: date, domain: appConfig.url.apiDomain } );
614
+ const html = htmlContent( { ...req.body, Uidomain: Uidomain, issueCount: issueCount, avgDownTime: avgDownTime, reportdate: date, content: response, date: date, domain: JSON.parse( process.env.URL ).apiDomain } );
615
615
  if ( isValidEmail( req.body.email ) ) {
616
- const result = await sendEmailWithSES( req.body.email, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
616
+ const result = await sendEmailWithSES( req.body.email, subject, html, attachments, JSON.parse( process.env.SES ).adminEmail );
617
617
  res.sendSuccess( result );
618
618
  }
619
619
  } catch ( error ) {
@@ -645,7 +645,7 @@ export async function camAngleChangeReport( req, res ) {
645
645
 
646
646
 
647
647
  const formattedPreviousDay = previousDay.format( 'DD-MM-YYYY' );
648
- const angleChange = await getOpenSearchData( 'camera-angle-change',
648
+ const angleChange = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).cameraAngleChange,
649
649
  {
650
650
  'query': {
651
651
  'bool': {
@@ -673,7 +673,7 @@ export async function camAngleChangeReport( req, res ) {
673
673
  if ( result && result.cameraAngleChangeStatus && result.camera_info.length > 0 ) {
674
674
  for ( let stream of result.camera_info ) {
675
675
  let params = {
676
- Bucket: appConfig.cloud.aws.bucket.cameraAngle,
676
+ Bucket: JSON.parse( process.env.BUCKET ).cameraAngle,
677
677
  file_path: stream.path,
678
678
  };
679
679
  let Image = await signedUrl( params );
@@ -703,7 +703,7 @@ export async function camAngleChangeReport( req, res ) {
703
703
  };
704
704
  let subject = `Camera Angle Modified - ${formattedPreviousDay}`;
705
705
  let html = `<div>We wanted to inform you that the camera angle in your stores has been adjusted recently.</div>`;
706
- let result = await sendEmailWithSES( req.body.toMail, subject, html, attachments, appConfig.cloud.aws.ses.adminEmail );
706
+ let result = await sendEmailWithSES( req.body.toMail, subject, html, attachments, JSON.parse( process.env.SES ).adminEmail );
707
707
  if ( result ) {
708
708
  res.sendSuccess( 'Email send successfully' );
709
709
  }
@@ -777,7 +777,7 @@ export async function edgeApplogsCheck( req, res ) {
777
777
  { 'timestamp': { 'order': 'desc' } },
778
778
  ],
779
779
  };
780
- const errorLogList = await getOpenSearchData( 'edgeapp_systemlogs', errorLog );
780
+ const errorLogList = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, errorLog );
781
781
 
782
782
  let result = [];
783
783
 
@@ -4,7 +4,7 @@ import { aggregateTangoTicket } from '../services/tangoTicket.service.js';
4
4
  import { findOneStore } from '../services/store.service.js';
5
5
  import dayjs from 'dayjs';
6
6
  import { findinfraReason } from '../services/infraReason.service.js';
7
- import { signedUrl, appConfig } from 'tango-app-api-middleware';
7
+ import { signedUrl } from 'tango-app-api-middleware';
8
8
  export async function storeTicketList( req, res ) {
9
9
  try {
10
10
  let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
@@ -137,10 +137,10 @@ export async function storeTicketList( req, res ) {
137
137
  },
138
138
  );
139
139
 
140
- if ( req.body.filter && req.body.filter !== '' ) {
140
+ if ( req.body.filter &&req.body.filter.length>0 ) {
141
141
  query.push( {
142
142
  $match: {
143
- primaryIssue: req.body.filter,
143
+ primaryIssue: { $in: req.body.filter },
144
144
  },
145
145
  } );
146
146
  }
@@ -324,7 +324,7 @@ export async function edgeAppLogTable( req, res ) {
324
324
  { 'timestamp': { 'order': 'desc' } },
325
325
  ],
326
326
  };
327
- let speedTest = await getOpenSearchData( 'edgeapp_systemlogs', internetSpeedQuery );
327
+ let speedTest = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, internetSpeedQuery );
328
328
  if ( speedTest&& speedTest.body.hits && speedTest.body.hits.hits.length > 0 ) {
329
329
  for ( const sourcedata of speedTest.body.hits.hits ) {
330
330
  if ( sourcedata._source ) {
@@ -371,23 +371,22 @@ export async function edgeAppLogTable( req, res ) {
371
371
  { 'timestamp': { 'order': 'desc' } },
372
372
  ],
373
373
  };
374
- let newFilesCount = await getOpenSearchData( 'edgeapp_systemlogs', FileCountQuery );
374
+ let newFilesCount = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, FileCountQuery );
375
375
  if ( newFilesCount&& newFilesCount.body.hits && newFilesCount.body.hits.hits.length > 0 ) {
376
376
  obj.files_pushed = 0;
377
- obj.files_genrated = 0;
377
+ obj.files_generated = 0;
378
378
  for ( let sourcedata of newFilesCount.body.hits.hits ) {
379
379
  if ( sourcedata._source ) {
380
380
  if ( Number( sourcedata._source.data.occuringTime.split( ':' )[0] )==obj.hour ) {
381
381
  obj.files_pushed = obj.files_pushed+Number( sourcedata._source.data.files_pushed );
382
- obj.files_genrated = obj.files_generated+Number( sourcedata._source.data.files_generated );
382
+ obj.files_generated = obj.files_generated+Number( sourcedata._source.data.files_generated );
383
383
  }
384
384
  }
385
385
  }
386
386
  } else {
387
387
  obj.files_pushed = '';
388
- obj.files_genrated = '';
388
+ obj.files_generated = '';
389
389
  }
390
-
391
390
  let downTimeQuery = {
392
391
  'size': 1,
393
392
  'query': {
@@ -413,7 +412,7 @@ export async function edgeAppLogTable( req, res ) {
413
412
  },
414
413
  },
415
414
  };
416
- const downtime = await getOpenSearchData( 'live_downtime_hourly_test1', downTimeQuery );
415
+ const downtime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery );
417
416
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
418
417
  if ( streamwiseDowntime.length > 0 ) {
419
418
  const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
@@ -426,7 +425,17 @@ export async function edgeAppLogTable( req, res ) {
426
425
  }
427
426
  }
428
427
  if ( req.body.export ) {
429
- await download( timeSlots, res );
428
+ const exportdata = [];
429
+ timeSlots.forEach( ( element ) => {
430
+ exportdata.push( {
431
+ 'Time Stamp': element.startTime+ '-'+ element.endTime,
432
+ 'Downtime': element.ticketId,
433
+ 'Avg Internet Speed': element.Date,
434
+ 'Files Genarated': element.issueClosedDate,
435
+ 'Files Pushed': element.primaryIssue,
436
+ } );
437
+ } );
438
+ await download( exportdata, res );
430
439
  return;
431
440
  }
432
441
  res.sendSuccess( timeSlots );
@@ -465,7 +474,6 @@ function generateTimeSlots( startHour, endHour, interval, req ) {
465
474
  };
466
475
 
467
476
  function getTimeDifference( start, end ) {
468
- console.log( start, end );
469
477
  let startTime = new Date( `1970-01-01T${start}Z` );
470
478
  let endTime = new Date( `1970-01-01T${end}Z` );
471
479
  let differenceInMilliseconds = endTime - startTime;
@@ -517,7 +525,8 @@ export async function viewedgeAppLog( req, res ) {
517
525
  },
518
526
  },
519
527
  };
520
- const appStartTime = await getOpenSearchData( 'edgeapp_systemlogs', appStartTimeQuery );
528
+ const appStartTime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, appStartTimeQuery );
529
+
521
530
  response.appStartTime = appStartTime.body.hits.hits.length > 0 ? appStartTime.body.hits.hits[0]._source.data.occuringTime : '';
522
531
 
523
532
  let appQuitTimeQuery = {
@@ -553,7 +562,7 @@ export async function viewedgeAppLog( req, res ) {
553
562
  { 'timestamp': { 'order': 'desc' } },
554
563
  ],
555
564
  };
556
- const appQuitTime = await getOpenSearchData( 'edgeapp_systemlogs', appQuitTimeQuery );
565
+ const appQuitTime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, appQuitTimeQuery );
557
566
  if ( appQuitTime.body.hits.hits&&appQuitTime.body.hits.hits.length > 0 ) {
558
567
  for ( const sourceData of appQuitTime.body.hits.hits ) {
559
568
  if ( Number( sourceData._source.data.occuringTime.split( ':' )[0] )== Number( fromTime.split( ':' )[0] ) ) {
@@ -595,7 +604,7 @@ export async function viewedgeAppLog( req, res ) {
595
604
  ],
596
605
  };
597
606
 
598
- const appCrashTime = await getOpenSearchData( 'edgeapp_systemlogs', appCrashTimeQuery );
607
+ const appCrashTime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, appCrashTimeQuery );
599
608
  if ( appCrashTime.body.hits.hits&&appCrashTime.body.hits.hits.length > 0 ) {
600
609
  for ( const sourceData of appCrashTime.body.hits.hits ) {
601
610
  if ( Number( sourceData._source.data.occuringTime.split( ':' )[0] )== Number( fromTime.split( ':' )[0] ) ) {
@@ -603,7 +612,7 @@ export async function viewedgeAppLog( req, res ) {
603
612
  }
604
613
  }
605
614
  }
606
- const screenStatus = await getOpenSearchData( 'edgeapp_systemlogs', {
615
+ const screenStatus = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, {
607
616
  'size': 1000,
608
617
  'query': {
609
618
  'bool': {
@@ -638,13 +647,11 @@ export async function viewedgeAppLog( req, res ) {
638
647
 
639
648
  } );
640
649
  if ( screenStatus&& screenStatus.body.hits.hits&&screenStatus.body.hits.hits.length > 0 ) {
641
- console.log( '==========', screenStatus.body.hits.hits.length );
642
650
  let suspendedTime;
643
651
  let resumedTime;
644
652
  const differences = [];
645
653
 
646
654
  for ( const sourceData of screenStatus.body.hits.hits ) {
647
- console.log( sourceData._source.data.occuringTime );
648
655
  if ( Number( sourceData._source.data.occuringTime.split( ':' )[0] )== Number( fromTime.split( ':' )[0] ) ) {
649
656
  if ( sourceData._source.data.message.trim() === 'SYSTEM SUSPENDED' ) {
650
657
  suspendedTime = sourceData._source.data.occuringTime;
@@ -664,7 +671,6 @@ export async function viewedgeAppLog( req, res ) {
664
671
  }
665
672
  }
666
673
  }
667
- console.log( differences );
668
674
  response.screenStatus = differences.length>0?`${differences[0].minutes}Mins ${differences[0].seconds}Sec`:'';
669
675
  }
670
676
  const FileCountQuery = {
@@ -701,25 +707,25 @@ export async function viewedgeAppLog( req, res ) {
701
707
  { 'timestamp': { 'order': 'desc' } },
702
708
  ],
703
709
  };
704
- const newFilesCount = await getOpenSearchData( 'edgeapp_systemlogs', FileCountQuery );
710
+ const newFilesCount = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, FileCountQuery );
705
711
  if ( newFilesCount&& newFilesCount.body.hits && newFilesCount.body.hits.hits.length > 0 ) {
706
- response.files_pushed = 0;
712
+ response.filesPushed = 0;
707
713
  response.files_genrated = 0;
708
714
  for ( const sourcedata of newFilesCount.body.hits.hits ) {
709
715
  if ( sourcedata._source ) {
710
- if ( Number( sourcedata._source.data.occuringTime.split( ':' )[0] )==response.hour ) {
711
- response.files_pushed = response.files_pushed+Number( sourcedata._source.data.files_pushed );
716
+ if ( Number( sourcedata._source.data.occuringTime.split( ':' )[0] )==Number( fromTime.split( ':' )[0] ) ) {
717
+ response.filesPushed = response.filesPushed+Number( sourcedata._source.data.files_pushed );
712
718
  response.files_genrated = response.files_generated+Number( sourcedata._source.data.files_generated );
713
719
  }
714
720
  }
715
721
  }
716
722
  } else {
717
- response.files_pushed = '';
723
+ response.filesPushed = '';
718
724
  response.files_genrated = '';
719
725
  }
720
726
 
721
727
 
722
- const antiVirus = await getOpenSearchData( 'edgeapp_systemlogs', {
728
+ const antiVirus = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, {
723
729
  'size': 1,
724
730
  'query': {
725
731
  'bool': {
@@ -765,7 +771,7 @@ export async function viewedgeAppLog( req, res ) {
765
771
 
766
772
  export async function cameraAngleChange( req, res ) {
767
773
  try {
768
- const angleChange = await getOpenSearchData( 'camera-angle-change',
774
+ const angleChange = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).cameraAngleChange,
769
775
  {
770
776
  'size': 1,
771
777
  'query': {
@@ -790,17 +796,17 @@ export async function cameraAngleChange( req, res ) {
790
796
  let changeDetected = result.camera_info.filter( ( cam ) => cam.stream == req.body.StreamName );
791
797
  if ( changeDetected.length == 1 ) {
792
798
  let params = {
793
- Bucket: appConfig.cloud.aws.bucket.cameraAngle,
799
+ Bucket: JSON.parse( process.env.BUCKET ).cameraAngle,
794
800
  file_path: changeDetected[0].path,
795
801
  };
796
802
  let Image = await signedUrl( params );
797
803
  let expectedparams = {
798
- Bucket: appConfig.cloud.aws.bucket.cameraAngle,
804
+ Bucket: JSON.parse( process.env.BUCKET ).cameraAngle,
799
805
  file_path: changeDetected[0].expected,
800
806
  };
801
807
  let expectedImage = await signedUrl( expectedparams );
802
808
  let actualparams = {
803
- Bucket: appConfig.cloud.aws.bucket.cameraAngle,
809
+ Bucket: JSON.parse( process.env.BUCKET ).cameraAngle,
804
810
  file_path: changeDetected[0].actual,
805
811
  };
806
812
  let actualImage = await signedUrl( actualparams );
@@ -900,8 +906,8 @@ export async function streamwiseDowntime( req, res ) {
900
906
  },
901
907
  },
902
908
  {
903
- 'terms': {
904
- 'doc.hour.keyword': [ obj.hour ],
909
+ 'term': {
910
+ 'doc.hour.keyword': obj.hour,
905
911
  },
906
912
  },
907
913
  ],
@@ -909,21 +915,18 @@ export async function streamwiseDowntime( req, res ) {
909
915
  },
910
916
  },
911
917
  };
912
- const downtime = await getOpenSearchData( 'live_downtime_hourly_test1', downTimeQuery );
918
+ const downtime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery );
913
919
 
914
920
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
915
921
  if ( streamwiseDowntime.length > 0 ) {
916
922
  for ( let stream of streamwiseDowntime ) {
917
923
  if ( stream.stream === req.body.stream ) {
918
924
  obj.downTime= stream.down_time;
919
- } else {
920
- obj.downTime= '';
921
925
  }
922
926
  }
923
927
  } else {
924
928
  obj.downTime= '';
925
929
  }
926
-
927
930
  timewise.push( obj );
928
931
  }
929
932
  res.sendSuccess( timewise );
@@ -966,7 +969,7 @@ export async function livecountCheck( inputData, req ) {
966
969
  },
967
970
  },
968
971
  };
969
- const downtime = await getOpenSearchData( 'live_downtime_hourly_test1', downTimeQuery );
972
+ const downtime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery );
970
973
  let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
971
974
  if ( streamwiseDowntime.length > 0 ) {
972
975
  const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
@@ -158,6 +158,7 @@ export async function userTicketList( req, res ) {
158
158
  storeId: '$basicDetails.storeId',
159
159
  storeName: '$basicDetails.storeName',
160
160
  clientId: '$basicDetails.clientId',
161
+ clientName: '$basicDetails.clientName',
161
162
  Date: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
162
163
  updatedAt: 1,
163
164
  ticketId: 1,
@@ -190,6 +191,7 @@ export async function userTicketList( req, res ) {
190
191
  $project: {
191
192
  storeId: 1,
192
193
  storeName: 1,
194
+ clientName: 1,
193
195
  updatedAt: 1,
194
196
  clientId: 1,
195
197
  Date: 1,
@@ -208,6 +210,7 @@ export async function userTicketList( req, res ) {
208
210
  _id: '$ticketId',
209
211
  storeId: { $first: '$storeId' },
210
212
  storeName: { $first: '$storeName' },
213
+ clientName: { $first: '$clientName' },
211
214
  clientId: { $first: '$clientId' },
212
215
  updatedAt: { $first: '$updatedAt' },
213
216
  Date: { $first: '$Date' },
@@ -234,13 +237,13 @@ export async function userTicketList( req, res ) {
234
237
  },
235
238
  } );
236
239
  }
237
- if ( req.body.filter && req.body.filter !== '' ) {
240
+ if ( req.body.filter && req.body.filter.length>0 ) {
238
241
  query.push( {
239
242
  $match: {
240
243
  $or: [
241
- { issueStatus: req.body.filter },
242
- { infraIssue: req.body.filter },
243
- { issueType: req.body.filter },
244
+ { issueStatus: { $in: req.body.filter } },
245
+ { infraIssue: { $in: req.body.filter } },
246
+ { issueType: { $in: req.body.filter } },
244
247
  ],
245
248
  },
246
249
  } );
@@ -198,7 +198,7 @@ export async function ticketExists( req, res, next ) {
198
198
  export async function validateTicketstatus( req, res, next ) {
199
199
  try {
200
200
  if ( req.body.issueType == 'infra' ) {
201
- if ( req.body.secondary.length>0 ) {
201
+ if ( req.body.secondary&&req.body.secondary.length>0 ) {
202
202
  if ( req.body.status == 'closed' ) {
203
203
  return res.sendSuccess( 'Ticket already closed' );
204
204
  }
@@ -269,28 +269,29 @@ export async function infraReasonExists( req, res, next ) {
269
269
  } ],
270
270
  },
271
271
  );
272
- } else {
273
- if ( req.body.primary == 'Application Issues' ) {
274
- let actionBy = '';
275
- if ( req.user.userType == 'tango' ) {
276
- actionBy = 'Tango';
277
- } else if ( req.user.userType == 'client' ) {
278
- actionBy = 'User';
279
- }
280
- req.body.ticketActivity.push( {
281
- actionType: 'issueUpdate',
282
- actionBy: actionBy,
283
- timeStamp: new Date(),
284
- IdentifiedBy: req.user.userName,
285
- comment: req.body.comment,
286
- reasons: [ {
287
- primaryIssue: req.body.primary,
288
- secondaryIssue: [],
289
- } ],
290
- },
291
- );
292
- }
293
272
  }
273
+ // else {
274
+ // if ( req.body.primary == 'Application Issues' ) {
275
+ // let actionBy = '';
276
+ // if ( req.user.userType == 'tango' ) {
277
+ // actionBy = 'Tango';
278
+ // } else if ( req.user.userType == 'client' ) {
279
+ // actionBy = 'User';
280
+ // }
281
+ // req.body.ticketActivity.push( {
282
+ // actionType: 'issueUpdate',
283
+ // actionBy: actionBy,
284
+ // timeStamp: new Date(),
285
+ // IdentifiedBy: req.user.userName,
286
+ // comment: req.body.comment,
287
+ // reasons: [ {
288
+ // primaryIssue: req.body.primary,
289
+ // secondaryIssue: [],
290
+ // } ],
291
+ // },
292
+ // );
293
+ // }
294
+ // }
294
295
 
295
296
 
296
297
  next();
@@ -313,20 +314,19 @@ export async function InfrastepstoResolve( req, res, next ) {
313
314
  secondaryIsssue: [ ...secondaryReason.stepstoResolve ],
314
315
  } );
315
316
  }
316
- if ( req.body.primary != 'Store Operation Issues' && req.body.primary != 'Application Issues' ) {
317
- req.body.ticketActivity.push( {
318
- actionType: 'stepsToResolve',
319
- actionBy: 'Tango',
320
- timeStamp: new Date(),
321
- IdentifiedBy: 'Tango',
322
- reasons: steptoReslove.map( ( item ) => ( {
323
- primaryIssue: item.primaryIssue,
324
- secondaryIssue: item.secondaryIsssue.map( ( issue ) => ( {
325
- name: issue.name, // Assuming each object has a 'name' property
326
- } ) ),
317
+
318
+ req.body.ticketActivity.push( {
319
+ actionType: 'stepsToResolve',
320
+ actionBy: 'Tango',
321
+ timeStamp: new Date(),
322
+ IdentifiedBy: 'Tango',
323
+ reasons: steptoReslove.map( ( item ) => ( {
324
+ primaryIssue: item.primaryIssue,
325
+ secondaryIssue: item.secondaryIsssue.map( ( issue ) => ( {
326
+ name: issue.name, // Assuming each object has a 'name' property
327
327
  } ) ),
328
- } );
329
- }
328
+ } ) ),
329
+ } );
330
330
  }
331
331
  next();
332
332
  } catch ( error ) {