tango-app-api-infra 3.0.65-dev → 3.0.67-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/index.js CHANGED
@@ -5,7 +5,10 @@ import { internalInfraRouter } from './src/routes/internalInfra.routes.js';
5
5
  import { userInfraRouter } from './src/routes/userInfra.routes.js';
6
6
  import { storeInfraRouter } from './src/routes/storeInfra.routes.js';
7
7
  import { clientInfraRouter } from './src/routes/clientInfra.routes.js';
8
+ import { employeeTrainigRouter } from './src/routes/employeetrainig.routes.js';
9
+ import { dataMismatchTicketRouter } from './src/routes/dataMismatch.routes.js';
8
10
 
9
- export { infraRouter, internalInfraRouter, userInfraRouter, storeInfraRouter, clientInfraRouter };
11
+
12
+ export { infraRouter, internalInfraRouter, userInfraRouter, storeInfraRouter, dataMismatchTicketRouter, clientInfraRouter, employeeTrainigRouter };
10
13
 
11
14
 
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "tango-app-api-infra",
3
- "version": "3.0.65-dev",
3
+ "version": "3.0.67-dev",
4
4
  "description": "infra",
5
- "main": "app.js",
5
+ "main": "index.js",
6
6
  "type": "module",
7
7
  "scripts": {
8
- "start": "nodemon --exec \"eslint --fix . && node app.js\""
8
+ "start": "nodemon --exec \"eslint --fix . && node index.js\""
9
9
  },
10
10
  "engines": {
11
11
  "node": ">=18.10.0"
@@ -25,9 +25,8 @@
25
25
  "joi-to-swagger": "^6.2.0",
26
26
  "mongodb": "^6.4.0",
27
27
  "nodemon": "^3.1.0",
28
- "swagger-ui-express": "^5.0.0",
29
- "tango-api-schema": "^2.0.93",
30
- "tango-app-api-middleware": "^1.0.61-dev",
28
+ "tango-api-schema": "^2.0.94",
29
+ "tango-app-api-middleware": "^1.0.63-dev",
31
30
  "winston": "^3.12.0",
32
31
  "winston-daily-rotate-file": "^5.0.0"
33
32
  },
@@ -10,7 +10,7 @@ import { getOpenSearchData } from 'tango-app-api-middleware';
10
10
  export async function infraCard( req, res ) {
11
11
  try {
12
12
  let date = await getUTC( new Date( req.body.fromDate ), new Date( req.body.toDate ) );
13
- let storeCount = await countDocumentsStore( { clientId: { $in: req.body.clientId }, status: 'active' } );
13
+ let storeCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId }, 'edge.firstFile': true, 'status': 'active' } );
14
14
  let infraStoreCount = await aggregateTangoTicket( [
15
15
  {
16
16
  $match: {
@@ -46,13 +46,14 @@ export async function infraCard( req, res ) {
46
46
  },
47
47
  },
48
48
  ] );
49
+
49
50
  let query = [ {
50
51
  $match: {
51
52
  $and: [
52
53
  { issueType: 'infra' },
54
+ { status: { $ne: 'closed' } },
53
55
  { 'ticketDetails.issueStatus': 'identified' },
54
56
  { 'basicDetails.clientId': { $in: req.body.clientId } },
55
- { 'ticketDetails.issueStatus': 'identified' },
56
57
  { createdAt: { $gte: date.start } },
57
58
  { createdAt: { $lte: date.end } },
58
59
  ],
@@ -148,9 +149,15 @@ export async function infraCard( req, res ) {
148
149
  }
149
150
  export async function installationCard( req, res ) {
150
151
  try {
151
- let onboardedCount = await countDocumentsStore( { clientId: { $in: req.body.clientId } } );
152
- let installedCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId }, 'edge.deployed': true } );
153
-
152
+ let onboardedCount = await countDocumentsStore( {
153
+ '$and': [
154
+ { 'clientId': { $in: req.body.clientId } },
155
+ ],
156
+ } );
157
+ let installedCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId },
158
+ 'edge.firstFile': true, 'status': 'active' } );
159
+ let deactiveCount = await countDocumentsStore( { 'clientId': { $in: req.body.clientId },
160
+ 'status': 'deactive' } );
154
161
  let yettoInstallCount = await aggregateTangoTicket( [
155
162
  {
156
163
  $match: {
@@ -207,9 +214,19 @@ export async function installationCard( req, res ) {
207
214
  issueIdentifiedBy: 1,
208
215
  primaryIssue: '$primaryIssue.reasons.primaryIssue',
209
216
  },
217
+ }, {
218
+ $group: {
219
+ _id: '$ticketId',
220
+ ticketId: { $first: '$ticketId' },
221
+ issueStatus: { $last: '$issueStatus' },
222
+ ticketType: { $last: '$ticketType' },
223
+ issueIdentifiedBy: { $last: '$issueIdentifiedBy' },
224
+ primaryIssue: { $last: '$primaryIssue' },
225
+ },
210
226
  },
211
227
  ];
212
228
  let installFailedCount = await aggregateTangoTicket( query );
229
+
213
230
  let issueList = await findinfraReason( { parentId: { '$exists': false } } );
214
231
  const categoryCounts = {};
215
232
  let response;
@@ -234,13 +251,14 @@ export async function installationCard( req, res ) {
234
251
  }
235
252
  res.sendSuccess( {
236
253
  onboardedStoresCount: onboardedCount,
254
+ inactiveStoresCount: deactiveCount,
237
255
  installedStoresCount: installedCount,
238
256
  yettoInstallCount: yettoInstallCount.length,
239
257
  installFailedCount: installFailedCount.length,
240
258
  infraIssues: response,
241
259
  } );
242
260
  } catch ( error ) {
243
- logger.error( { error: error, function: 'infraCard' } );
261
+ logger.error( { error: error, function: 'installationCard' } );
244
262
  return res.sendError( error, 500 );
245
263
  }
246
264
  }
@@ -251,6 +269,7 @@ export async function infraIssuesTable( req, res ) {
251
269
  $match: {
252
270
  $and: [
253
271
  { issueType: 'infra' },
272
+ { status: { $ne: 'closed' } },
254
273
  { 'basicDetails.clientId': { $in: req.body.clientId } },
255
274
  { 'ticketDetails.issueStatus': 'identified' },
256
275
  { createdAt: { $gte: date.start } },
@@ -443,6 +462,18 @@ export async function InstallationIssuesTable( req, res ) {
443
462
  primaryIssue: { $ifNull: [ '$primaryIssue.reasons.primaryIssue', '-' ] },
444
463
  },
445
464
  },
465
+ {
466
+ $group: {
467
+ _id: '$storeId',
468
+ createdAt: { $first: '$createdAt' },
469
+ clientName: { $first: '$clientName' },
470
+ storeId: { $first: '$storeId' },
471
+ clientId: { $first: '$clientId' },
472
+ storeName: { $first: '$storeName' },
473
+ status: { $last: '$status' },
474
+ primaryIssue: { $last: '$primaryIssue' },
475
+ },
476
+ },
446
477
  ];
447
478
  if ( req.body.searchValue && req.body.searchValue !== '' ) {
448
479
  query.push( {
@@ -659,6 +690,7 @@ export async function hourWiseDownstores( req, res ) {
659
690
  let query = [ {
660
691
  $match: {
661
692
  clientId: req.body.clientId,
693
+ status: 'active',
662
694
  },
663
695
  },
664
696
  {
@@ -761,7 +793,7 @@ function downStoresCheck( data, inputData ) {
761
793
  const average = sum / streamwiseDowntime.length;
762
794
  obj[obj.startTime + '-' + obj.endTime] = Math.round( average );
763
795
  } else {
764
- obj[obj.startTime + '-' + obj.endTime] = 0;
796
+ obj[obj.startTime + '-' + obj.endTime] = '';
765
797
  }
766
798
 
767
799
  timewise.push( obj );
@@ -0,0 +1,23 @@
1
+
2
+ import { findOneTangoTicket, createTangoTicket } from '../services/tangoTicket.service.js';
3
+ import { logger } from 'tango-app-api-middleware';
4
+ export async function createTicket( req, res ) {
5
+ try {
6
+ let ticketExist = await findOneTangoTicket( { 'issueType': req.body.issueType, 'issueDate': ( new Date( req.body.Date ) ), 'basicDetails.storeId': req.body.storeId } );
7
+
8
+ if ( ticketExist ) {
9
+ return res.sendSuccess( 'MAT Ticket Already Exists for the store' );
10
+ }
11
+ req.body.ticketDetails = {};
12
+ req.body.ticketDetails.dataMismatch = req.body.dataMismatch;
13
+ req.body.issueDate = new Date( req.body.Date );
14
+ req.body.ticketId = 'TE_DM_' + new Date().valueOf();
15
+ let create = await createTangoTicket( req.body );
16
+ if ( create ) {
17
+ res.sendSuccess( 'Ticket Created Successfully' );
18
+ }
19
+ } catch ( error ) {
20
+ logger.error( { error: error, function: 'createTicket Data Mismatch' } );
21
+ return res.sendError( error, 500 );
22
+ }
23
+ }
@@ -0,0 +1,50 @@
1
+
2
+ import { createTangoTicket, findOneTangoTicket, updateOneTangoTicket } from '../services/tangoTicket.service.js';
3
+ import { logger } from 'tango-app-api-middleware';
4
+ export async function createTicket( req, res ) {
5
+ try {
6
+ let ticketExist = await findOneTangoTicket( { 'issueType': req.body.issueType, 'basicDetails.storeId': req.body.storeId } );
7
+ if ( ticketExist ) {
8
+ return res.sendSuccess( 'MAT Ticket Already Exists for the store' );
9
+ }
10
+
11
+ req.body.issueDate = new Date( req.body.Date );
12
+ req.body.ticketId = 'TE_MAT_' + new Date().valueOf();
13
+ let create = await createTangoTicket( req.body );
14
+ if ( create ) {
15
+ res.sendSuccess( 'Ticket Created Successfully' );
16
+ }
17
+ } catch ( error ) {
18
+ logger.error( { error: error, function: 'createTicket mat' } );
19
+ return res.sendError( error, 500 );
20
+ }
21
+ }
22
+
23
+ export async function updatecomment( req, res ) {
24
+ try {
25
+ if ( req.body.comment != '' ) {
26
+ req.body.ticketActivity.push( {
27
+ actionType: 'comment',
28
+ actionBy: 'Tango',
29
+ timeStamp: new Date(),
30
+ IdentifiedBy: req.user.userName,
31
+ comment: req.body.comment,
32
+ } );
33
+ }
34
+ let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, { ticketActivity: req.body.ticketActivity } );
35
+ if ( updateTicket ) {
36
+ res.sendSuccess( 'Ticket Updated Successfully' );
37
+ }
38
+ } catch ( error ) {
39
+ logger.error( { error: error, function: 'updatecomment mat' } );
40
+ return res.sendError( error, 500 );
41
+ }
42
+ }
43
+ export async function activityLog( req, res ) {
44
+ try {
45
+ res.sendSuccess( req.body );
46
+ } catch ( error ) {
47
+ logger.error( { error: error, function: 'activityLog mat' } );
48
+ return res.sendError( error, 500 );
49
+ }
50
+ }