tango-app-api-infra 3.0.30-dev → 3.0.31-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.30-dev",
3
+ "version": "3.0.31-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  "mongodb": "^6.4.0",
24
24
  "nodemon": "^3.1.0",
25
25
  "tango-api-schema": "^2.0.65",
26
- "tango-app-api-middleware": "^1.0.49-dev",
26
+ "tango-app-api-middleware": "^1.0.51-dev",
27
27
  "winston": "^3.12.0",
28
28
  "winston-daily-rotate-file": "^5.0.0"
29
29
  },
@@ -133,7 +133,7 @@ export async function storeTicketcard( req, res ) {
133
133
  { 'ticketDetails.issueStatus': 'identified' },
134
134
  { issueType: 'infra' },
135
135
  { createdAt: { $gte: date.start } },
136
- { createdAt: { $lte: date.start } },
136
+ { createdAt: { $lte: date.end } },
137
137
  ],
138
138
 
139
139
  },
@@ -51,8 +51,8 @@ export async function userTicketList( req, res ) {
51
51
  query.push( {
52
52
  $match: {
53
53
  $and: [
54
- { createdAt: { $gte: date.start } },
55
- { createdAt: { $lte: date.end } },
54
+ { updatedAt: { $gte: date.start } },
55
+ { updatedAt: { $lte: date.end } },
56
56
  ],
57
57
  },
58
58
  } );
@@ -171,47 +171,50 @@ export async function ticketExists( req, res, next ) {
171
171
  };
172
172
  export async function infraReasonExists( req, res, next ) {
173
173
  try {
174
- let primaryReason = await findOneinfraReason( { name: req.body.primary } );
175
- if ( !primaryReason ) {
176
- return res.sendError( 'Primary Reason Not exists in database', 500 );
177
- }
178
- const secondary = [];
179
- const steptoReslove = [];
180
- for ( let i = 0; i < req.body.secondary.length; i++ ) {
181
- let secondaryReason = await findOneinfraReason( { name: req.body.secondary[i] } );
182
- if ( !secondaryReason ) {
183
- return res.sendError( `secondary Reason - ${req.body.secondary[i]} Not exists in database`, 500 );
174
+ if ( req.body.primary&&req.body.secondary&&req.body.secondary.length ) {
175
+ let primaryReason = await findOneinfraReason( { name: req.body.primary } );
176
+ if ( !primaryReason ) {
177
+ return res.sendError( 'Primary Reason Not exists in database', 500 );
184
178
  }
185
- secondary.push( {
186
- name: secondaryReason.name,
187
- } );
188
- let resolveSteps = [];
189
- for ( let i = 0; i < secondaryReason.stepstoResolve.length; i++ ) {
190
- resolveSteps.push( {
191
- name: secondaryReason.stepstoResolve[i].name,
179
+ const secondary = [];
180
+ const steptoReslove = [];
181
+ for ( let i = 0; i < req.body.secondary.length; i++ ) {
182
+ let secondaryReason = await findOneinfraReason( { name: req.body.secondary[i] } );
183
+ if ( !secondaryReason ) {
184
+ return res.sendError( `secondary Reason - ${req.body.secondary[i]} Not exists in database`, 500 );
185
+ }
186
+ secondary.push( {
187
+ name: secondaryReason.name,
188
+ } );
189
+ let resolveSteps = [];
190
+ for ( let i = 0; i < secondaryReason.stepstoResolve.length; i++ ) {
191
+ resolveSteps.push( {
192
+ name: secondaryReason.stepstoResolve[i].name,
193
+ } );
194
+ }
195
+ steptoReslove.push( {
196
+ primaryIssue: secondaryReason.name,
197
+ secondaryIsssue: [ ...resolveSteps ],
192
198
  } );
193
199
  }
194
- steptoReslove.push( {
195
- primaryIssue: secondaryReason.name,
196
- secondaryIsssue: [ ...resolveSteps ],
197
- } );
198
- }
199
- let actionBy = '';
200
- if ( req.user.userType == 'tango' ) {
201
- actionBy = 'Tango';
202
- } else if ( req.user.userType == 'client' ) {
203
- actionBy = 'User';
200
+ let actionBy = '';
201
+ if ( req.user.userType == 'tango' ) {
202
+ actionBy = 'Tango';
203
+ } else if ( req.user.userType == 'client' ) {
204
+ actionBy = 'User';
205
+ }
206
+ req.body.ticketActivity.push( {
207
+ actionType: 'issueUpdate',
208
+ actionBy: actionBy,
209
+ comment: req.body.comment,
210
+ reasons: [ {
211
+ primaryIssue: primaryReason.name,
212
+ secondaryIssue: secondary,
213
+ } ],
214
+ },
215
+ );
204
216
  }
205
- req.body.ticketActivity.push( {
206
- actionType: 'issueUpdate',
207
- actionBy: actionBy,
208
- comment: req.body.comment,
209
- reasons: [ {
210
- primaryIssue: primaryReason.name,
211
- secondaryIssue: secondary,
212
- } ],
213
- },
214
- );
217
+
215
218
  next();
216
219
  } catch ( error ) {
217
220
  logger.error( { error: error, function: 'infraReasonExists' } );
@@ -221,27 +224,29 @@ export async function infraReasonExists( req, res, next ) {
221
224
  export async function InfrastepstoResolve( req, res, next ) {
222
225
  try {
223
226
  const steptoReslove = [];
224
- for ( let i = 0; i < req.body.secondary.length; i++ ) {
225
- let secondaryReason = await findOneinfraReason( { name: req.body.secondary[i] } );
226
- if ( !secondaryReason ) {
227
- return res.sendError( `secondary Reason - ${req.body.secondary[i]} Not exists in database`, 500 );
227
+ if ( req.body.primary&&req.body.secondary&&req.body.secondary.length ) {
228
+ for ( let i = 0; i < req.body.secondary.length; i++ ) {
229
+ let secondaryReason = await findOneinfraReason( { name: req.body.secondary[i] } );
230
+ if ( !secondaryReason ) {
231
+ return res.sendError( `secondary Reason - ${req.body.secondary[i]} Not exists in database`, 500 );
232
+ }
233
+ steptoReslove.push( {
234
+ primaryIssue: secondaryReason.name,
235
+ secondaryIsssue: [ ...secondaryReason.stepstoResolve ],
236
+ } );
228
237
  }
229
- steptoReslove.push( {
230
- primaryIssue: secondaryReason.name,
231
- secondaryIsssue: [ ...secondaryReason.stepstoResolve ],
232
- } );
233
- }
234
- if ( req.body.primary != 'Store Operation Issues' && req.body.primary != 'Application Issues' ) {
235
- req.body.ticketActivity.push( {
236
- actionType: 'stepsToResolve',
237
- actionBy: 'Tango',
238
- reasons: steptoReslove.map( ( item ) => ( {
239
- primaryIssue: item.primaryIssue,
240
- secondaryIssue: item.secondaryIsssue.map( ( issue ) => ( {
241
- name: issue.name, // Assuming each object has a 'name' property
238
+ if ( req.body.primary != 'Store Operation Issues' && req.body.primary != 'Application Issues' ) {
239
+ req.body.ticketActivity.push( {
240
+ actionType: 'stepsToResolve',
241
+ actionBy: 'Tango',
242
+ reasons: steptoReslove.map( ( item ) => ( {
243
+ primaryIssue: item.primaryIssue,
244
+ secondaryIssue: item.secondaryIsssue.map( ( issue ) => ( {
245
+ name: issue.name, // Assuming each object has a 'name' property
246
+ } ) ),
242
247
  } ) ),
243
- } ) ),
244
- } );
248
+ } );
249
+ }
245
250
  }
246
251
  next();
247
252
  } catch ( error ) {
@@ -264,13 +269,29 @@ export async function InfraAlert( req, res, next ) {
264
269
  await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'hibernation': new Date( req.body.hibernationDays ) } );
265
270
  } else {
266
271
  if ( req.body.issueType == 'infra' ) {
267
- let client = await findOneClient( { clientId: req.body.basicDetails.clientId }, { ticketConfigs: 1 } );
268
- let statusCheckAlertTime = dayjs().add( client.ticketConfigs.statusCheckAlert, 'hours' ).format( 'YYYY-MM-DD hh:mm' );
269
- req.body.ticketActivity.push( {
270
- actionType: 'statusCheck',
271
- actionBy: 'Tango',
272
- statusCheckAlertTime: statusCheckAlertTime,
273
- } );
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
+ }
294
+ }
274
295
  }
275
296
  }
276
297