tango-app-api-infra 3.1.28 → 3.1.30
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
|
@@ -912,6 +912,12 @@ export async function getInfraIssues( req, res ) {
|
|
|
912
912
|
camera[index].thumbnailImage = await signedUrl( { Bucket: JSON.parse( process.env.BUCKET ).baseImage, file_path: camera[index].thumbnailImage } );
|
|
913
913
|
}
|
|
914
914
|
}
|
|
915
|
+
|
|
916
|
+
// for ( let i =0; i< mergeValue.length; i++ ) {
|
|
917
|
+
// let issueDateChanged = new Date( mergeValue[i].issueDate );
|
|
918
|
+
// mergeValue[i].issueDate = dayjs( issueDateChanged ).format( 'DD-MM-YYYY' );
|
|
919
|
+
// }
|
|
920
|
+
|
|
915
921
|
logger.info( { message: camera } );
|
|
916
922
|
return res.sendSuccess( { result: mergeValue, streams: camera, highCountTicketDetails: getHighCountTicket[0] || defaultValue } );
|
|
917
923
|
} catch ( error ) {
|
|
@@ -76,7 +76,7 @@ export async function clientList( req, res ) {
|
|
|
76
76
|
try {
|
|
77
77
|
let clientList = await findClient( { status: { $in: [ 'active', 'hold' ] } },
|
|
78
78
|
{ 'clientName': 1, 'clientId': 1, 'ticketConfigs': 1 } );
|
|
79
|
-
|
|
79
|
+
logger.info( { 'clientList': clientList, 'message': 'clientList' } );
|
|
80
80
|
res.sendSuccess( clientList );
|
|
81
81
|
} catch ( error ) {
|
|
82
82
|
logger.error( { error: error, function: 'basicList' } );
|
|
@@ -93,7 +93,7 @@ export async function basicList( req, res ) {
|
|
|
93
93
|
}
|
|
94
94
|
let storeList = await findStore( { 'clientId': { $in: clients }, 'status': 'active', 'edge.firstFile': true },
|
|
95
95
|
{ 'storeName': 1, 'storeId': 1, 'ticketConfigs': 1, 'clientId': 1, 'storeProfile.open': 1, 'storeProfile.close': 1, 'storeProfile.timeZone': 1 } );
|
|
96
|
-
|
|
96
|
+
logger.info( { 'storeList': storeList, 'message': 'storeList' } );
|
|
97
97
|
|
|
98
98
|
res.sendSuccess( storeList );
|
|
99
99
|
} catch ( error ) {
|
|
@@ -106,7 +106,7 @@ export async function basicList( req, res ) {
|
|
|
106
106
|
export async function setTicketTime( req, res ) {
|
|
107
107
|
try {
|
|
108
108
|
let input = req.body;
|
|
109
|
-
logger.info( { input: input
|
|
109
|
+
logger.info( { 'input': input, 'message': 'setTicketTime' } );
|
|
110
110
|
for ( let i = 0; i < input.stores.length; i++ ) {
|
|
111
111
|
await updateOneStore( { storeId: input.stores[i].storeId }, { 'ticketConfigs.nextTicektGenerationTime': new Date( input.stores[i].nextTicektGenerationTime ) } );
|
|
112
112
|
};
|
|
@@ -120,7 +120,7 @@ export async function setTicketTime( req, res ) {
|
|
|
120
120
|
export async function downStoresList( req, res ) {
|
|
121
121
|
try {
|
|
122
122
|
let storesList = await findStore( { 'ticketConfigs.hibernation': { $lt: new Date() }, 'ticketConfigs.nextTicektGenerationTime': new Date( req.body.getTime ) }, { storeId: 1, storeName: 1, storeProfile: 1, ticketConfigs: 1 } );
|
|
123
|
-
logger.info( { storesList: storesList,
|
|
123
|
+
logger.info( { 'storesList': storesList, 'message': 'downStoresList' } );
|
|
124
124
|
if ( storesList.length > 0 ) {
|
|
125
125
|
res.sendSuccess( storesList );
|
|
126
126
|
} else {
|
|
@@ -163,58 +163,63 @@ export async function updateRefreshTicket( req, res ) {
|
|
|
163
163
|
let getTicket = await findOneTangoTicket( { ticketId: ticket.ticketId } );
|
|
164
164
|
await updateOneTangoTicket( { ticketId: ticket.ticketId }, { 'ticketDetails.ticketType': 'refreshticket', 'ticketDetails.refreshTicketStatus': 'notidentified' } );
|
|
165
165
|
await updateOneTangoTicketunset( { ticketId: ticket.ticketId }, { 'ticketDetails.addressingUser': 1 } );
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
'
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
166
|
+
if ( getTicket&&getTicket.basicDetails ) {
|
|
167
|
+
let getclient = await findOneClient( { clientId: getTicket.basicDetails.clientId } );
|
|
168
|
+
if ( getclient.ticketConfigs.emailAlert ) {
|
|
169
|
+
let downTimeQuery = {
|
|
170
|
+
'size': 1,
|
|
171
|
+
'query': {
|
|
172
|
+
'bool': {
|
|
173
|
+
'must': [
|
|
174
|
+
{
|
|
175
|
+
'term': {
|
|
176
|
+
'doc.date.keyword': dayjs( getTicket.issueDate ).format( 'DD-MM-YYYY' ),
|
|
177
|
+
},
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
'term': {
|
|
181
|
+
'doc.store_id.keyword': getTicket.basicDetails.storeId,
|
|
182
|
+
},
|
|
183
|
+
},
|
|
181
184
|
|
|
182
|
-
|
|
185
|
+
],
|
|
183
186
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
187
|
+
},
|
|
188
|
+
},
|
|
189
|
+
};
|
|
190
|
+
let downtimetotal;
|
|
191
|
+
const downtime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery );
|
|
192
|
+
let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
|
|
193
|
+
if ( streamwiseDowntime.length > 0 ) {
|
|
194
|
+
const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
|
|
195
|
+
return accumulator + currentValue.down_time;
|
|
196
|
+
}, 0 );
|
|
197
|
+
const average = sum / streamwiseDowntime.length;
|
|
198
|
+
downtimetotal = Math.round( average );
|
|
199
|
+
} else {
|
|
200
|
+
downtimetotal = 0;
|
|
201
|
+
}
|
|
202
|
+
let Timestamp = dayjs().format( 'YYYY-MM-DD HH:mm' );
|
|
203
|
+
const attachments = null;
|
|
204
|
+
const subject = `Tango Eye - Infra Ticket Closed for ${getTicket.basicDetails.storeName} `;
|
|
205
|
+
const fileContent = readFileSync( join() + '/src/hbs/refreshTicket.hbs', 'utf8' );
|
|
206
|
+
const htmlContent = handlebars.compile( fileContent );
|
|
207
|
+
let store = await findOneStore( { storeId: getTicket.basicDetails.storeId } );
|
|
208
|
+
if ( store.spocDetails && store.spocDetails.length > 0 ) {
|
|
209
|
+
let spocEmail = store.spocDetails[0].email;
|
|
210
|
+
let spocName = store.spocDetails[0].name;
|
|
211
|
+
let Issue = getTicket.ticketActivity.filter( ( a ) => a.actionType == 'issueUpdate' );
|
|
212
|
+
let primaryIssue = 'Not Identified';
|
|
213
|
+
if ( Issue.length > 0 && Issue[0].reasons.length > 0 ) {
|
|
214
|
+
primaryIssue = Issue[0].reasons[0].primaryIssue;
|
|
215
|
+
}
|
|
216
|
+
let Uidomain = `${JSON.parse( process.env.URL ).domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
|
|
217
|
+
|
|
218
|
+
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 } );
|
|
219
|
+
if ( spocEmail && isValidEmail( spocEmail ) ) {
|
|
220
|
+
await sendEmailWithSES( spocEmail, subject, html, attachments, JSON.parse( process.env.SES ).adminEmail );
|
|
221
|
+
}
|
|
222
|
+
}
|
|
218
223
|
}
|
|
219
224
|
}
|
|
220
225
|
}
|
|
@@ -357,6 +357,9 @@ export async function edgeAppLogTable( req, res ) {
|
|
|
357
357
|
const downtimeData = downtimeResult?.body?.hits?.hits ?? [];
|
|
358
358
|
|
|
359
359
|
for ( const obj of timeSlots ) {
|
|
360
|
+
if ( ( obj.hour ).toString().length === 1 ) {
|
|
361
|
+
obj.hour = obj.hour.toString().padStart( 2, '0' );
|
|
362
|
+
}
|
|
360
363
|
const hour = obj.hour;
|
|
361
364
|
obj.startTime = dayjs( obj.from ).format( 'hh:mm A' );
|
|
362
365
|
obj.endTime = dayjs( obj.to ).format( 'hh:mm A' );
|
|
@@ -785,6 +788,10 @@ export async function streamwiseDowntime( req, res ) {
|
|
|
785
788
|
const downTimeIndex = parsedOpenSearch.downTimeHourly;
|
|
786
789
|
|
|
787
790
|
const batchRequests = TimeSlots.map( async ( obj ) => {
|
|
791
|
+
if ( ( obj.hour ).toString().length ===1 ) {
|
|
792
|
+
obj.hour = obj.hour.toString().padStart( 2, '0' );
|
|
793
|
+
}
|
|
794
|
+
|
|
788
795
|
const formattedDate = dayjs( obj.from ).format( 'DD-MM-YYYY' );
|
|
789
796
|
const downTimeQuery = {
|
|
790
797
|
size: 1,
|