tango-app-api-infra 3.0.33-dev → 3.0.35-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.33-dev",
3
+ "version": "3.0.35-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -22,7 +22,7 @@
22
22
  "handlebars": "^4.7.8",
23
23
  "mongodb": "^6.4.0",
24
24
  "nodemon": "^3.1.0",
25
- "tango-api-schema": "^2.0.66",
25
+ "tango-api-schema": "^2.0.67",
26
26
  "tango-app-api-middleware": "^1.0.52-dev",
27
27
  "winston": "^3.12.0",
28
28
  "winston-daily-rotate-file": "^5.0.0"
@@ -63,7 +63,6 @@ export async function infraCard( req, res ) {
63
63
  ticketId: 1,
64
64
  issueStatus: '$ticketDetails.issueStatus',
65
65
  ticketType: '$ticketDetails.ticketType',
66
- issueIdentifiedBy: '$ticketDetails.issueIdentifiedBy',
67
66
  primaryIssue: {
68
67
  $filter: {
69
68
  input: '$ticketActivity',
@@ -88,7 +87,7 @@ export async function infraCard( req, res ) {
88
87
  ticketId: 1,
89
88
  issueStatus: 1,
90
89
  ticketType: 1,
91
- issueIdentifiedBy: 1,
90
+ issueIdentifiedBy: '$primaryIssue.actionBy',
92
91
  primaryIssue: '$primaryIssue.reasons.primaryIssue',
93
92
  },
94
93
  },
@@ -112,7 +111,6 @@ export async function infraCard( req, res ) {
112
111
  );
113
112
  }
114
113
  let ticketList = await aggregateTangoTicket( query );
115
-
116
114
  let issueList = await findinfraReason( { parentId: { '$exists': false } } );
117
115
  const categoryCounts = {};
118
116
  let response;
@@ -302,6 +300,7 @@ export async function infraIssuesTable( req, res ) {
302
300
  storeName: 1,
303
301
  createdAt: 1,
304
302
  ticketId: 1,
303
+ actionBy: '$primaryIssue.actionBy',
305
304
  issueIdentifiedDate: { $ifNull: [ '$issueIdentifiedDate', '-' ] },
306
305
  issueClosedDate: { $ifNull: [ '$issueClosedDate', '-' ] },
307
306
  status: 1,
@@ -315,6 +314,7 @@ export async function infraIssuesTable( req, res ) {
315
314
  storeId: { $first: '$storeId' },
316
315
  clientId: { $first: '$clientId' },
317
316
  ticketId: { $first: '$ticketId' },
317
+ actionBy: { $first: '$actionBy' },
318
318
  storeName: { $first: '$storeName' },
319
319
  createdAt: { $first: '$createdAt' },
320
320
  issueIdentifiedDate: { $last: '$issueIdentifiedDate' },
@@ -342,6 +342,15 @@ export async function infraIssuesTable( req, res ) {
342
342
  },
343
343
  } );
344
344
  }
345
+ if ( req.body.filter && req.body.filter.length > 0 ) {
346
+ query.push(
347
+ {
348
+ $match: {
349
+ actionBy: { $in: req.body.filter },
350
+ },
351
+ },
352
+ );
353
+ }
345
354
  if ( req.body.sortColumName && req.body.sortColumName !== '' && req.body.sortBy ) {
346
355
  query.push( {
347
356
  $sort: { [req.body.sortColumName]: req.body.sortBy },
@@ -14,6 +14,7 @@ export async function createTicket( req, res ) {
14
14
  req.body.ticketActivity = [ {
15
15
  actionType: 'defaultInfra',
16
16
  actionBy: 'Tango',
17
+ IdentifiedBy: 'Tango',
17
18
  } ];
18
19
  }
19
20
  if ( req.body.issueType == 'installation' ) {
@@ -42,6 +43,7 @@ export async function bulkcreateTicket( req, res ) {
42
43
  data.ticketActivity = [ {
43
44
  actionType: 'defaultInfra',
44
45
  actionBy: 'Tango',
46
+ IdentifiedBy: 'Tango',
45
47
  } ];
46
48
  }
47
49
  if ( data.issueType == 'installation' ) {
@@ -67,6 +69,7 @@ export async function updateStatus( req, res ) {
67
69
  req.body.ticketActivity.push( {
68
70
  actionType: 'statusChange',
69
71
  actionBy: 'Tango',
72
+ IdentifiedBy: req.user.userName,
70
73
  } );
71
74
  }
72
75
  req.body.ticketDetails.addressingUser = req.user._id;
@@ -79,6 +82,7 @@ export async function updateStatus( req, res ) {
79
82
  req.body.ticketActivity.push( {
80
83
  actionType: 'statusChange',
81
84
  actionBy: 'User',
85
+ IdentifiedBy: req.user.userName,
82
86
  } );
83
87
  }
84
88
  req.body.ticketDetails.addressingClient = req.user._id;
@@ -166,9 +170,16 @@ export async function updateInstallationTicket( req, res ) {
166
170
  updateValue = { 'ticketDetails.installationStatus': req.body.installationStatus, 'status': 'inprogress' };
167
171
  }
168
172
  if ( req.body.actionType && req.body.actionType != '' ) {
173
+ let actionBy = '';
174
+ if ( req.user.userType == 'tango' ) {
175
+ actionBy = 'Tango';
176
+ } else if ( req.user.userType == 'client' ) {
177
+ actionBy = 'User';
178
+ }
169
179
  req.body.ticketActivity.push( {
170
180
  actionType: req.body.actionType,
171
- actionBy: 'Tango',
181
+ actionBy: actionBy,
182
+ IdentifiedBy: actionBy == 'Tango' ? actionBy : req.user.userName,
172
183
  } );
173
184
  updateValue = { ticketActivity: req.body.ticketActivity };
174
185
  }
@@ -214,10 +225,12 @@ export async function AlertTicketReply( req, res ) {
214
225
  actionType: 'statusCheckReply',
215
226
  actionBy: 'User',
216
227
  statusCheckReply: req.body.statusCheckReply,
228
+ IdentifiedBy: req.user.userName,
217
229
  hibernationDays: req.body.hibernationDays,
218
230
  } );
219
231
  req.body.ticketActivity.push( {
220
232
  actionType: 'statusCheckMonitor',
233
+ IdentifiedBy: 'Tango',
221
234
  actionBy: 'Tango',
222
235
  } );
223
236
  await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketActivity': req.body.ticketActivity } );
@@ -234,7 +247,8 @@ export async function AlertTicketReply( req, res ) {
234
247
  export async function uploadAttachments( req, res ) {
235
248
  try {
236
249
  if ( req.files.img && req.files.img.length > 0 ) {
237
- let attachments = [];
250
+ let oldticket = await findOneTangoTicket( { ticketId: req.params.ticketId } );
251
+ let attachments = oldticket.attachments;
238
252
  for ( let singleImg in req.files.img ) {
239
253
  if ( req.files.img.hasOwnProperty( singleImg ) ) {
240
254
  let params = {
@@ -259,7 +273,27 @@ export async function uploadAttachments( req, res ) {
259
273
  res.sendSuccess( 'Uploaded successfully' );
260
274
  }
261
275
  } else {
262
-
276
+ let oldticket = await findOneTangoTicket( { ticketId: req.params.ticketId } );
277
+ let attachments = oldticket.attachments;
278
+ let params = {
279
+ Bucket: 'tango-client-sandbox',
280
+ Key: req.params.ticketId + '/',
281
+ ContentType: 'multipart/form-data',
282
+ body: req.files.img.data,
283
+ fileName: req.files.img.name,
284
+ };
285
+ let upload = await fileUpload( params );
286
+ if ( upload ) {
287
+ let getObject = {
288
+ fileName: req.files.img.name,
289
+ filePath: req.params.ticketId + '/' + req.files.img.name,
290
+ };
291
+ attachments.push( getObject );
292
+ }
293
+ let updateTicket = await updateOneTangoTicket( { ticketId: req.params.ticketId }, { attachments: attachments } );
294
+ if ( updateTicket ) {
295
+ res.sendSuccess( 'Uploaded successfully' );
296
+ }
263
297
  }
264
298
  } catch ( error ) {
265
299
  logger.error( { error: error, function: 'uploadAttachments' } );
@@ -74,6 +74,7 @@ export async function userTicketList( req, res ) {
74
74
  $project: {
75
75
  storeId: '$basicDetails.storeId',
76
76
  Date: { $dateToString: { format: '%d-%m-%Y', date: '$issueDate' } },
77
+ updatedAt: 1,
77
78
  ticketId: 1,
78
79
  issueType: 1,
79
80
  status: 1,
@@ -102,6 +103,7 @@ export async function userTicketList( req, res ) {
102
103
  {
103
104
  $project: {
104
105
  storeId: 1,
106
+ updatedAt: 1,
105
107
  Date: 1,
106
108
  ticketId: 1,
107
109
  issueStatus: 1,
@@ -116,6 +118,7 @@ export async function userTicketList( req, res ) {
116
118
  $group: {
117
119
  _id: '$ticketId',
118
120
  storeId: { $first: '$storeId' },
121
+ updatedAt: { $first: '$updatedAt' },
119
122
  Date: { $first: '$Date' },
120
123
  ticketId: { $first: '$ticketId' },
121
124
  issueType: { $first: '$issueType' },
@@ -171,7 +171,7 @@ export async function ticketExists( req, res, next ) {
171
171
  };
172
172
  export async function infraReasonExists( req, res, next ) {
173
173
  try {
174
- if ( req.body.primary&&req.body.secondary&&req.body.secondary.length ) {
174
+ if ( req.body.primary && req.body.secondary && req.body.secondary.length ) {
175
175
  let primaryReason = await findOneinfraReason( { name: req.body.primary } );
176
176
  if ( !primaryReason ) {
177
177
  return res.sendError( 'Primary Reason Not exists in database', 500 );
@@ -206,6 +206,7 @@ export async function infraReasonExists( req, res, next ) {
206
206
  req.body.ticketActivity.push( {
207
207
  actionType: 'issueUpdate',
208
208
  actionBy: actionBy,
209
+ IdentifiedBy: req.user.userName,
209
210
  comment: req.body.comment,
210
211
  reasons: [ {
211
212
  primaryIssue: primaryReason.name,
@@ -213,8 +214,29 @@ export async function infraReasonExists( req, res, next ) {
213
214
  } ],
214
215
  },
215
216
  );
217
+ } else {
218
+ if ( req.body.primary == 'Application Issues' ) {
219
+ let actionBy = '';
220
+ if ( req.user.userType == 'tango' ) {
221
+ actionBy = 'Tango';
222
+ } else if ( req.user.userType == 'client' ) {
223
+ actionBy = 'User';
224
+ }
225
+ req.body.ticketActivity.push( {
226
+ actionType: 'issueUpdate',
227
+ actionBy: actionBy,
228
+ IdentifiedBy: req.user.userName,
229
+ comment: req.body.comment,
230
+ reasons: [ {
231
+ primaryIssue: req.body.primary,
232
+ secondaryIssue: [],
233
+ } ],
234
+ },
235
+ );
236
+ }
216
237
  }
217
238
 
239
+
218
240
  next();
219
241
  } catch ( error ) {
220
242
  logger.error( { error: error, function: 'infraReasonExists' } );
@@ -224,7 +246,7 @@ export async function infraReasonExists( req, res, next ) {
224
246
  export async function InfrastepstoResolve( req, res, next ) {
225
247
  try {
226
248
  const steptoReslove = [];
227
- if ( req.body.primary&&req.body.secondary&&req.body.secondary.length ) {
249
+ if ( req.body.primary && req.body.secondary && req.body.secondary.length ) {
228
250
  for ( let i = 0; i < req.body.secondary.length; i++ ) {
229
251
  let secondaryReason = await findOneinfraReason( { name: req.body.secondary[i] } );
230
252
  if ( !secondaryReason ) {
@@ -239,6 +261,7 @@ export async function InfrastepstoResolve( req, res, next ) {
239
261
  req.body.ticketActivity.push( {
240
262
  actionType: 'stepsToResolve',
241
263
  actionBy: 'Tango',
264
+ IdentifiedBy: 'Tango',
242
265
  reasons: steptoReslove.map( ( item ) => ( {
243
266
  primaryIssue: item.primaryIssue,
244
267
  secondaryIssue: item.secondaryIsssue.map( ( issue ) => ( {
@@ -263,38 +286,40 @@ export async function InfraAlert( req, res, next ) {
263
286
  await updateOneStore( { storeId: req.body.basicDetails.storeId }, { 'ticketConfigs.hibernation': new Date( req.body.hibernationDays ) } );
264
287
  req.body.ticketActivity.push( {
265
288
  actionType: 'statusCheckReply',
266
- actionBy: 'Tango',
289
+ actionBy: 'User',
290
+ IdentifiedBy: req.user.userName,
267
291
  hibernationDays: req.body.hibernationDays,
268
292
  } );
269
293
  await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'hibernation': new Date( req.body.hibernationDays ) } );
270
294
  } else {
271
295
  if ( req.body.issueType == 'infra' ) {
272
- if ( req.body.primary&&req.body.secondary&&req.body.secondary.length ) {
273
- let client = await findOneClient( { clientId: req.body.basicDetails.clientId }, { ticketConfigs: 1 } );
274
- let statusCheckAlertTime = dayjs().add( client.ticketConfigs.statusCheckAlert, 'hours' ).format( 'YYYY-MM-DD hh:mm' );
275
- req.body.ticketActivity.push( {
276
- actionType: 'statusCheck',
277
- actionBy: 'Tango',
278
- statusCheckAlertTime: statusCheckAlertTime,
279
- } );
280
- } else {
281
- if ( req.body.comment !='' ) {
282
- let actionBy = '';
283
- if ( req.user.userType == 'tango' ) {
284
- actionBy = 'Tango';
285
- } else if ( req.user.userType == 'client' ) {
286
- actionBy = 'User';
287
- }
288
- req.body.ticketActivity.push( {
289
- actionType: 'comment',
290
- actionBy: actionBy,
291
- comment: req.body.comment,
292
- } );
293
- }
296
+ let client = await findOneClient( { clientId: req.body.basicDetails.clientId }, { ticketConfigs: 1 } );
297
+ let statusCheckAlertTime = dayjs().add( client.ticketConfigs.statusCheckAlert, 'hours' ).format( 'YYYY-MM-DD hh:mm' );
298
+ req.body.ticketActivity.push( {
299
+ actionType: 'statusCheck',
300
+ timeStamp: statusCheckAlertTime,
301
+ actionBy: 'Tango',
302
+ IdentifiedBy: 'Tango',
303
+ statusCheckAlertTime: statusCheckAlertTime,
304
+ } );
305
+ }
306
+ if ( req.body.comment != '' && req.body.secondary.length == 0 ) {
307
+ let actionBy = '';
308
+ if ( req.user.userType == 'tango' ) {
309
+ actionBy = 'Tango';
310
+ } else if ( req.user.userType == 'client' ) {
311
+ actionBy = 'User';
294
312
  }
313
+ req.body.ticketActivity.push( {
314
+ actionType: 'comment',
315
+ actionBy: actionBy,
316
+ IdentifiedBy: req.user.userName,
317
+ comment: req.body.comment,
318
+ } );
295
319
  }
296
320
  }
297
321
 
322
+
298
323
  next();
299
324
  } catch ( error ) {
300
325
  logger.error( { error: error, function: 'InfraAlert' } );