tango-app-api-infra 3.0.103-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 +2 -2
- package/src/controllers/clientInfra.controller.js +2 -2
- package/src/controllers/dataMismatch.controller.js +7 -7
- package/src/controllers/infra.controllers.js +12 -12
- package/src/controllers/internalInfra.controller.js +17 -17
- package/src/controllers/storeInfra.controlller.js +19 -22
- package/src/controllers/userInfra.controller.js +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tango-app-api-infra",
|
|
3
|
-
"version": "3.0.
|
|
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.
|
|
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
|
},
|
|
@@ -865,7 +865,7 @@ export async function livecountCheck( data, inputData ) {
|
|
|
865
865
|
for ( const obj of TimeSlots ) {
|
|
866
866
|
obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
|
|
867
867
|
obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
|
|
868
|
-
const liveCount = await getOpenSearchData(
|
|
868
|
+
const liveCount = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).dataNotReceivedHour,
|
|
869
869
|
{
|
|
870
870
|
'size': 1,
|
|
871
871
|
'query': {
|
|
@@ -1152,7 +1152,7 @@ function downStoresCheck( data, inputData ) {
|
|
|
1152
1152
|
for ( const obj of TimeSlots ) {
|
|
1153
1153
|
obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
|
|
1154
1154
|
obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
|
|
1155
|
-
const downTime = await getOpenSearchData(
|
|
1155
|
+
const downTime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly,
|
|
1156
1156
|
{
|
|
1157
1157
|
'size': 1,
|
|
1158
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,
|
|
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:
|
|
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 =
|
|
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 =
|
|
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:
|
|
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( `${
|
|
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:
|
|
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,
|
|
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(
|
|
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 = `${
|
|
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:
|
|
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,
|
|
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' );
|
|
@@ -294,7 +294,7 @@ export async function viewTicket( req, res ) {
|
|
|
294
294
|
if ( ticket.attachments.hasOwnProperty( index ) ) {
|
|
295
295
|
let file = ticket.attachments[index];
|
|
296
296
|
let params = {
|
|
297
|
-
Bucket:
|
|
297
|
+
Bucket: JSON.parse( process.env.BUCKET ).ticket,
|
|
298
298
|
file_path: file.filePath,
|
|
299
299
|
};
|
|
300
300
|
let attachments = await signedUrl( params );
|
|
@@ -357,7 +357,7 @@ export async function uploadAttachments( req, res ) {
|
|
|
357
357
|
for ( let singleImg in req.files.img ) {
|
|
358
358
|
if ( req.files.img.hasOwnProperty( singleImg ) ) {
|
|
359
359
|
let params = {
|
|
360
|
-
Bucket:
|
|
360
|
+
Bucket: JSON.parse( process.env.BUCKET ).ticket,
|
|
361
361
|
Key: req.params.ticketId + '/',
|
|
362
362
|
ContentType: 'multipart/form-data',
|
|
363
363
|
body: req.files.img[singleImg].data,
|
|
@@ -381,7 +381,7 @@ export async function uploadAttachments( req, res ) {
|
|
|
381
381
|
let oldticket = await findOneTangoTicket( { ticketId: req.params.ticketId } );
|
|
382
382
|
let attachments = oldticket.attachments;
|
|
383
383
|
let params = {
|
|
384
|
-
Bucket:
|
|
384
|
+
Bucket: JSON.parse( process.env.BUCKET ).ticket,
|
|
385
385
|
Key: req.params.ticketId + '/',
|
|
386
386
|
ContentType: 'multipart/form-data',
|
|
387
387
|
body: req.files.img.data,
|
|
@@ -557,7 +557,7 @@ export async function saveInfraEmailConfig( req, res ) {
|
|
|
557
557
|
},
|
|
558
558
|
};
|
|
559
559
|
|
|
560
|
-
await insertOpenSearchData(
|
|
560
|
+
await insertOpenSearchData( JSON.parse( process.env.OPENSEARCH ).activityLog, logObj );
|
|
561
561
|
|
|
562
562
|
|
|
563
563
|
res.sendSuccess( 'Updated Successfully' );
|
|
@@ -761,7 +761,7 @@ export async function getInfraIssues( req, res ) {
|
|
|
761
761
|
return res.sendError( 'NO Data Found', 204 );
|
|
762
762
|
}
|
|
763
763
|
for ( let i =0; i< mergeValue.length; i++ ) {
|
|
764
|
-
const downTime = await getOpenSearchData(
|
|
764
|
+
const downTime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly,
|
|
765
765
|
{
|
|
766
766
|
'size': 100,
|
|
767
767
|
'query': {
|
|
@@ -785,7 +785,7 @@ export async function getInfraIssues( req, res ) {
|
|
|
785
785
|
|
|
786
786
|
} );
|
|
787
787
|
|
|
788
|
-
const speedTest = await getOpenSearchData(
|
|
788
|
+
const speedTest = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs,
|
|
789
789
|
{
|
|
790
790
|
'size': 1,
|
|
791
791
|
'query': {
|
|
@@ -898,7 +898,7 @@ export async function getInfraIssues( req, res ) {
|
|
|
898
898
|
const camera = await aggregateCamera( camQuery );
|
|
899
899
|
for ( let index = 0; index < camera.length; index++ ) {
|
|
900
900
|
if ( camera?.[index]?.thumbnailImage ) {
|
|
901
|
-
camera[index].thumbnailImage = await signedUrl( { Bucket:
|
|
901
|
+
camera[index].thumbnailImage = await signedUrl( { Bucket: JSON.parse( process.env.BUCKET ).baseImage, file_path: camera[index].thumbnailImage } );
|
|
902
902
|
}
|
|
903
903
|
}
|
|
904
904
|
logger.info( { message: camera } );
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
|
|
2
|
-
import { logger, getOpenSearchData
|
|
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(
|
|
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 = `${
|
|
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:
|
|
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,
|
|
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(
|
|
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 = `${
|
|
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:
|
|
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,
|
|
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: `${
|
|
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 = `${
|
|
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:
|
|
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,
|
|
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(
|
|
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:
|
|
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,
|
|
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(
|
|
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
|
|
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 ) );
|
|
@@ -324,7 +324,7 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
324
324
|
{ 'timestamp': { 'order': 'desc' } },
|
|
325
325
|
],
|
|
326
326
|
};
|
|
327
|
-
let speedTest = await getOpenSearchData(
|
|
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,7 +371,7 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
371
371
|
{ 'timestamp': { 'order': 'desc' } },
|
|
372
372
|
],
|
|
373
373
|
};
|
|
374
|
-
let newFilesCount = await getOpenSearchData(
|
|
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
377
|
obj.files_generated = 0;
|
|
@@ -379,7 +379,7 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
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.
|
|
382
|
+
obj.files_generated = obj.files_generated+Number( sourcedata._source.data.files_generated );
|
|
383
383
|
}
|
|
384
384
|
}
|
|
385
385
|
}
|
|
@@ -412,7 +412,7 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
412
412
|
},
|
|
413
413
|
},
|
|
414
414
|
};
|
|
415
|
-
const downtime = await getOpenSearchData(
|
|
415
|
+
const downtime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery );
|
|
416
416
|
let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
|
|
417
417
|
if ( streamwiseDowntime.length > 0 ) {
|
|
418
418
|
const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
|
|
@@ -525,7 +525,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
525
525
|
},
|
|
526
526
|
},
|
|
527
527
|
};
|
|
528
|
-
const appStartTime = await getOpenSearchData(
|
|
528
|
+
const appStartTime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, appStartTimeQuery );
|
|
529
529
|
|
|
530
530
|
response.appStartTime = appStartTime.body.hits.hits.length > 0 ? appStartTime.body.hits.hits[0]._source.data.occuringTime : '';
|
|
531
531
|
|
|
@@ -562,7 +562,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
562
562
|
{ 'timestamp': { 'order': 'desc' } },
|
|
563
563
|
],
|
|
564
564
|
};
|
|
565
|
-
const appQuitTime = await getOpenSearchData(
|
|
565
|
+
const appQuitTime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, appQuitTimeQuery );
|
|
566
566
|
if ( appQuitTime.body.hits.hits&&appQuitTime.body.hits.hits.length > 0 ) {
|
|
567
567
|
for ( const sourceData of appQuitTime.body.hits.hits ) {
|
|
568
568
|
if ( Number( sourceData._source.data.occuringTime.split( ':' )[0] )== Number( fromTime.split( ':' )[0] ) ) {
|
|
@@ -604,7 +604,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
604
604
|
],
|
|
605
605
|
};
|
|
606
606
|
|
|
607
|
-
const appCrashTime = await getOpenSearchData(
|
|
607
|
+
const appCrashTime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, appCrashTimeQuery );
|
|
608
608
|
if ( appCrashTime.body.hits.hits&&appCrashTime.body.hits.hits.length > 0 ) {
|
|
609
609
|
for ( const sourceData of appCrashTime.body.hits.hits ) {
|
|
610
610
|
if ( Number( sourceData._source.data.occuringTime.split( ':' )[0] )== Number( fromTime.split( ':' )[0] ) ) {
|
|
@@ -612,7 +612,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
612
612
|
}
|
|
613
613
|
}
|
|
614
614
|
}
|
|
615
|
-
const screenStatus = await getOpenSearchData(
|
|
615
|
+
const screenStatus = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, {
|
|
616
616
|
'size': 1000,
|
|
617
617
|
'query': {
|
|
618
618
|
'bool': {
|
|
@@ -707,7 +707,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
707
707
|
{ 'timestamp': { 'order': 'desc' } },
|
|
708
708
|
],
|
|
709
709
|
};
|
|
710
|
-
const newFilesCount = await getOpenSearchData(
|
|
710
|
+
const newFilesCount = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, FileCountQuery );
|
|
711
711
|
if ( newFilesCount&& newFilesCount.body.hits && newFilesCount.body.hits.hits.length > 0 ) {
|
|
712
712
|
response.filesPushed = 0;
|
|
713
713
|
response.files_genrated = 0;
|
|
@@ -725,7 +725,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
725
725
|
}
|
|
726
726
|
|
|
727
727
|
|
|
728
|
-
const antiVirus = await getOpenSearchData(
|
|
728
|
+
const antiVirus = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).edgeAppSystemLogs, {
|
|
729
729
|
'size': 1,
|
|
730
730
|
'query': {
|
|
731
731
|
'bool': {
|
|
@@ -771,7 +771,7 @@ export async function viewedgeAppLog( req, res ) {
|
|
|
771
771
|
|
|
772
772
|
export async function cameraAngleChange( req, res ) {
|
|
773
773
|
try {
|
|
774
|
-
const angleChange = await getOpenSearchData(
|
|
774
|
+
const angleChange = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).cameraAngleChange,
|
|
775
775
|
{
|
|
776
776
|
'size': 1,
|
|
777
777
|
'query': {
|
|
@@ -796,17 +796,17 @@ export async function cameraAngleChange( req, res ) {
|
|
|
796
796
|
let changeDetected = result.camera_info.filter( ( cam ) => cam.stream == req.body.StreamName );
|
|
797
797
|
if ( changeDetected.length == 1 ) {
|
|
798
798
|
let params = {
|
|
799
|
-
Bucket:
|
|
799
|
+
Bucket: JSON.parse( process.env.BUCKET ).cameraAngle,
|
|
800
800
|
file_path: changeDetected[0].path,
|
|
801
801
|
};
|
|
802
802
|
let Image = await signedUrl( params );
|
|
803
803
|
let expectedparams = {
|
|
804
|
-
Bucket:
|
|
804
|
+
Bucket: JSON.parse( process.env.BUCKET ).cameraAngle,
|
|
805
805
|
file_path: changeDetected[0].expected,
|
|
806
806
|
};
|
|
807
807
|
let expectedImage = await signedUrl( expectedparams );
|
|
808
808
|
let actualparams = {
|
|
809
|
-
Bucket:
|
|
809
|
+
Bucket: JSON.parse( process.env.BUCKET ).cameraAngle,
|
|
810
810
|
file_path: changeDetected[0].actual,
|
|
811
811
|
};
|
|
812
812
|
let actualImage = await signedUrl( actualparams );
|
|
@@ -906,8 +906,8 @@ export async function streamwiseDowntime( req, res ) {
|
|
|
906
906
|
},
|
|
907
907
|
},
|
|
908
908
|
{
|
|
909
|
-
'
|
|
910
|
-
'doc.hour.keyword':
|
|
909
|
+
'term': {
|
|
910
|
+
'doc.hour.keyword': obj.hour,
|
|
911
911
|
},
|
|
912
912
|
},
|
|
913
913
|
],
|
|
@@ -915,21 +915,18 @@ export async function streamwiseDowntime( req, res ) {
|
|
|
915
915
|
},
|
|
916
916
|
},
|
|
917
917
|
};
|
|
918
|
-
const downtime = await getOpenSearchData(
|
|
918
|
+
const downtime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery );
|
|
919
919
|
|
|
920
920
|
let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
|
|
921
921
|
if ( streamwiseDowntime.length > 0 ) {
|
|
922
922
|
for ( let stream of streamwiseDowntime ) {
|
|
923
923
|
if ( stream.stream === req.body.stream ) {
|
|
924
924
|
obj.downTime= stream.down_time;
|
|
925
|
-
} else {
|
|
926
|
-
obj.downTime= '';
|
|
927
925
|
}
|
|
928
926
|
}
|
|
929
927
|
} else {
|
|
930
928
|
obj.downTime= '';
|
|
931
929
|
}
|
|
932
|
-
|
|
933
930
|
timewise.push( obj );
|
|
934
931
|
}
|
|
935
932
|
res.sendSuccess( timewise );
|
|
@@ -972,7 +969,7 @@ export async function livecountCheck( inputData, req ) {
|
|
|
972
969
|
},
|
|
973
970
|
},
|
|
974
971
|
};
|
|
975
|
-
const downtime = await getOpenSearchData(
|
|
972
|
+
const downtime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery );
|
|
976
973
|
let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
|
|
977
974
|
if ( streamwiseDowntime.length > 0 ) {
|
|
978
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' },
|