tango-app-api-infra 3.1.34-beta.45 → 3.1.34-beta.46
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
|
@@ -210,18 +210,18 @@ export async function infraCard( req, res ) {
|
|
|
210
210
|
} );
|
|
211
211
|
response.unshift( {
|
|
212
212
|
name: 'All Issues',
|
|
213
|
-
count: infraStoreCount.length > 0 ? infraStoreCount[0].notidentifiedcount+ticketList.length: 0,
|
|
213
|
+
count: infraStoreCount.length > 0 ? req.body.filter && req.body.filter.length > 0?ticketList.length:( infraStoreCount[0].notidentifiedcount+ticketList.length ): 0,
|
|
214
214
|
} );
|
|
215
215
|
response.push( {
|
|
216
216
|
name: 'Issues Not Identified',
|
|
217
|
-
count: infraStoreCount.length > 0 ? infraStoreCount[0].notidentifiedcount : 0,
|
|
217
|
+
count: infraStoreCount.length > 0 ?( req.body.filter && req.body.filter.length > 0 )?0: infraStoreCount[0].notidentifiedcount : 0,
|
|
218
218
|
} );
|
|
219
219
|
res.sendSuccess( {
|
|
220
220
|
total: storeCount,
|
|
221
221
|
liveStoreCount: infraStoreCount.length > 0 ? storeCount - infraStoreCount[0].infraCount : storeCount,
|
|
222
222
|
infraStoreCount: infraStoreCount.length > 0 ? infraStoreCount[0].notidentifiedcount+ticketList.length : 0,
|
|
223
223
|
identifiedcount: infraStoreCount.length > 0 ? ticketList.length : 0,
|
|
224
|
-
notidentifiedcount: infraStoreCount.length > 0 ? infraStoreCount[0].notidentifiedcount : 0,
|
|
224
|
+
notidentifiedcount: infraStoreCount.length > 0 ?( req.body.filter && req.body.filter.length > 0 )?0: infraStoreCount[0].notidentifiedcount : 0,
|
|
225
225
|
infraIssues: response,
|
|
226
226
|
} );
|
|
227
227
|
} catch ( error ) {
|
|
@@ -586,7 +586,7 @@ export async function infraIssuesTable( req, res ) {
|
|
|
586
586
|
|
|
587
587
|
|
|
588
588
|
if ( req.body.filter && req.body.filter.length > 0 ) {
|
|
589
|
-
req.body.filter.push( '' );
|
|
589
|
+
// req.body.filter.push( '' );
|
|
590
590
|
query.push(
|
|
591
591
|
{
|
|
592
592
|
$match: {
|
|
@@ -874,7 +874,7 @@ export async function OutsideUserListv2( req, res ) {
|
|
|
874
874
|
query.push( {
|
|
875
875
|
$match: {
|
|
876
876
|
$or: [
|
|
877
|
-
{
|
|
877
|
+
{ name: { $regex: req.body.searchValue, $options: 'i' } },
|
|
878
878
|
{ email: { $regex: req.body.searchValue, $options: 'i' } },
|
|
879
879
|
],
|
|
880
880
|
},
|
|
@@ -899,7 +899,6 @@ export async function OutsideUserListv2( req, res ) {
|
|
|
899
899
|
const result = await aggregatemailonlyuser( query );
|
|
900
900
|
|
|
901
901
|
for ( let data of result ) {
|
|
902
|
-
console.log( data );
|
|
903
902
|
let storelist = data.clusters.map( ( data ) => data.storeId );
|
|
904
903
|
data.Finalstores = [ ...data.stores, ...storelist ];
|
|
905
904
|
data.Finalstores = [ ...new Set( data.Finalstores ) ];
|
|
@@ -1581,6 +1580,14 @@ export async function infraTable( req, res ) {
|
|
|
1581
1580
|
refreshTicketStatus: '$ticketDetails.refreshTicketStatus',
|
|
1582
1581
|
status: 1,
|
|
1583
1582
|
createdAt: 1,
|
|
1583
|
+
issueClosedDate: 1,
|
|
1584
|
+
issueTime: {
|
|
1585
|
+
$dateToString: {
|
|
1586
|
+
format: '%H:%M',
|
|
1587
|
+
date: '$createdAt',
|
|
1588
|
+
timezone: 'Asia/Kolkata', // Replace with your desired timezone
|
|
1589
|
+
},
|
|
1590
|
+
},
|
|
1584
1591
|
issueDate: 1,
|
|
1585
1592
|
addressingUser: { $toObjectId: '$ticketDetails.addressingUser' },
|
|
1586
1593
|
primaryIssue: {
|
|
@@ -1636,6 +1643,8 @@ export async function infraTable( req, res ) {
|
|
|
1636
1643
|
addressingUser: 1,
|
|
1637
1644
|
ticketStatus: 1,
|
|
1638
1645
|
ticketType: 1,
|
|
1646
|
+
issueTime: 1,
|
|
1647
|
+
issueClosedDate: 1,
|
|
1639
1648
|
refreshTicketStatus: 1,
|
|
1640
1649
|
ticketId: 1,
|
|
1641
1650
|
issueDate: { $ifNull: [ '$issueDate', '' ] },
|
|
@@ -1685,6 +1694,8 @@ export async function infraTable( req, res ) {
|
|
|
1685
1694
|
storeName: { $first: '$storeName' },
|
|
1686
1695
|
ticketStatus: { $first: '$ticketStatus' },
|
|
1687
1696
|
ticketType: { $first: '$ticketType' },
|
|
1697
|
+
issueTime: { $first: '$issueTime' },
|
|
1698
|
+
issueClosedDate: { $first: '$issueClosedDate' },
|
|
1688
1699
|
refreshTicketStatus: { $first: '$refreshTicketStatus' },
|
|
1689
1700
|
userName: { $first: { $ifNull: [ '$user.userName', '-' ] } },
|
|
1690
1701
|
userEmail: { $first: { $ifNull: [ '$user.email', '-' ] } },
|
|
@@ -1836,6 +1847,8 @@ export async function infraTable( req, res ) {
|
|
|
1836
1847
|
exportdata.push( {
|
|
1837
1848
|
'Ticket ID': element.ticketId,
|
|
1838
1849
|
'Created Date': dayjs( element.issueDate ).format( 'DD MMM, YYYY' ),
|
|
1850
|
+
'Created Time': dayjs( element.createdAt ).format( 'hh:mm a' ),
|
|
1851
|
+
'Closed Time': element.issueClosedDate? dayjs( element.issueClosedDate ).format( 'hh:mm a' ):'--',
|
|
1839
1852
|
'Brand Name': element.clientName,
|
|
1840
1853
|
'Brand ID': element.clientId,
|
|
1841
1854
|
'Store Name': element.storeName,
|
|
@@ -168,63 +168,66 @@ export async function updateRefreshTicket( req, res ) {
|
|
|
168
168
|
try {
|
|
169
169
|
for ( let ticket of req.body.TicketList ) {
|
|
170
170
|
let getTicket = await findOneTangoTicket( { ticketId: ticket.ticketId } );
|
|
171
|
-
await
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
if (
|
|
176
|
-
let
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
'
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
171
|
+
let findStore = await findOneStore( { storeId: getTicket.basicDetails.storeId, status: 'active' } );
|
|
172
|
+
if ( findStore ) {
|
|
173
|
+
await updateOneTangoTicket( { ticketId: ticket.ticketId }, { 'ticketDetails.ticketType': 'refreshticket', 'ticketDetails.refreshTicketStatus': 'notidentified' } );
|
|
174
|
+
await updateOneTangoTicketunset( { ticketId: ticket.ticketId }, { 'ticketDetails.addressingUser': 1 } );
|
|
175
|
+
if ( getTicket && getTicket.basicDetails ) {
|
|
176
|
+
let getclient = await findOneClient( { clientId: getTicket.basicDetails.clientId } );
|
|
177
|
+
if ( getclient && getclient.ticketConfigs && getclient.ticketConfigs.emailAlert ) {
|
|
178
|
+
let downTimeQuery = {
|
|
179
|
+
'size': 1,
|
|
180
|
+
'query': {
|
|
181
|
+
'bool': {
|
|
182
|
+
'must': [
|
|
183
|
+
{
|
|
184
|
+
'term': {
|
|
185
|
+
'doc.date.keyword': dayjs( getTicket.issueDate ).format( 'DD-MM-YYYY' ),
|
|
186
|
+
},
|
|
184
187
|
},
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
188
|
+
{
|
|
189
|
+
'term': {
|
|
190
|
+
'doc.store_id.keyword': getTicket.basicDetails.storeId,
|
|
191
|
+
},
|
|
189
192
|
},
|
|
190
|
-
},
|
|
191
193
|
|
|
192
|
-
|
|
194
|
+
],
|
|
193
195
|
|
|
196
|
+
},
|
|
194
197
|
},
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
downtimetotal = 0;
|
|
208
|
-
}
|
|
209
|
-
let Timestamp = dayjs().format( 'YYYY-MM-DD HH:mm' );
|
|
210
|
-
const attachments = null;
|
|
211
|
-
const subject = `Tango Eye - Infra Ticket Closed for ${getTicket.basicDetails.storeName} `;
|
|
212
|
-
const fileContent = readFileSync( join() + '/src/hbs/refreshTicket.hbs', 'utf8' );
|
|
213
|
-
const htmlContent = handlebars.compile( fileContent );
|
|
214
|
-
let store = await findOneStore( { storeId: getTicket.basicDetails.storeId } );
|
|
215
|
-
if ( store.spocDetails && store.spocDetails.length > 0 ) {
|
|
216
|
-
let spocEmail = store.spocDetails[0].email;
|
|
217
|
-
let spocName = store.spocDetails[0].name;
|
|
218
|
-
let Issue = getTicket.ticketActivity.filter( ( a ) => a.actionType == 'issueUpdate' );
|
|
219
|
-
let primaryIssue = 'Not Identified';
|
|
220
|
-
if ( Issue.length > 0 && Issue[0].reasons.length > 0 ) {
|
|
221
|
-
primaryIssue = Issue[0].reasons[0].primaryIssue;
|
|
198
|
+
};
|
|
199
|
+
let downtimetotal;
|
|
200
|
+
const downtime = await getOpenSearchData( JSON.parse( process.env.OPENSEARCH ).downTimeHourly, downTimeQuery );
|
|
201
|
+
let streamwiseDowntime = downtime.body.hits.hits.length > 0 ? downtime.body.hits.hits[0]._source.doc.streamwise_downtime : [];
|
|
202
|
+
if ( streamwiseDowntime.length > 0 ) {
|
|
203
|
+
const sum = streamwiseDowntime.reduce( ( accumulator, currentValue ) => {
|
|
204
|
+
return accumulator + currentValue.down_time;
|
|
205
|
+
}, 0 );
|
|
206
|
+
const average = sum / streamwiseDowntime.length;
|
|
207
|
+
downtimetotal = Math.round( average );
|
|
208
|
+
} else {
|
|
209
|
+
downtimetotal = 0;
|
|
222
210
|
}
|
|
223
|
-
let
|
|
211
|
+
let Timestamp = dayjs().format( 'YYYY-MM-DD HH:mm' );
|
|
212
|
+
const attachments = null;
|
|
213
|
+
const subject = `Tango Eye - Infra Ticket Closed for ${getTicket.basicDetails.storeName} `;
|
|
214
|
+
const fileContent = readFileSync( join() + '/src/hbs/refreshTicket.hbs', 'utf8' );
|
|
215
|
+
const htmlContent = handlebars.compile( fileContent );
|
|
216
|
+
let store = await findOneStore( { storeId: getTicket.basicDetails.storeId } );
|
|
217
|
+
if ( store.spocDetails && store.spocDetails.length > 0 ) {
|
|
218
|
+
let spocEmail = store.spocDetails[0].email;
|
|
219
|
+
let spocName = store.spocDetails[0].name;
|
|
220
|
+
let Issue = getTicket.ticketActivity.filter( ( a ) => a.actionType == 'issueUpdate' );
|
|
221
|
+
let primaryIssue = 'Not Identified';
|
|
222
|
+
if ( Issue.length > 0 && Issue[0].reasons.length > 0 ) {
|
|
223
|
+
primaryIssue = Issue[0].reasons[0].primaryIssue;
|
|
224
|
+
}
|
|
225
|
+
let Uidomain = `${JSON.parse( process.env.URL ).domain}/manage/stores/infra-ticket?storeId=${getTicket.basicDetails.storeId}`;
|
|
224
226
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
227
|
+
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 } );
|
|
228
|
+
if ( spocEmail && isValidEmail( spocEmail ) ) {
|
|
229
|
+
await sendEmailWithSES( spocEmail, subject, html, attachments, JSON.parse( process.env.SES ).adminEmail );
|
|
230
|
+
}
|
|
228
231
|
}
|
|
229
232
|
}
|
|
230
233
|
}
|
|
@@ -156,8 +156,8 @@ export async function storeTicketList( req, res ) {
|
|
|
156
156
|
exportdata.push( {
|
|
157
157
|
'STORE ID': element.storeId,
|
|
158
158
|
'TICKET ID': element.ticketId,
|
|
159
|
-
'DATE': element.Date,
|
|
160
|
-
'ISSUE CLOSED DATE': element.issueClosedDate,
|
|
159
|
+
'DATE': dayjs( element.Date ).format( 'DD MMM, YYYY' ),
|
|
160
|
+
'ISSUE CLOSED DATE': dayjs( element.issueClosedDate ).format( 'DD MMM, YYYY' ),
|
|
161
161
|
'PRIMARY ISSUE': element.primaryIssue,
|
|
162
162
|
'SECONDARY ISSUE': element.secondaryIssue,
|
|
163
163
|
'STATUS': element.status,
|