tango-app-api-infra 3.0.94-dev → 3.0.95-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.94-dev",
3
+ "version": "3.0.95-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -26,7 +26,7 @@
26
26
  "mongodb": "^6.4.0",
27
27
  "nodemon": "^3.1.0",
28
28
  "swagger-ui-express": "^5.0.0",
29
- "tango-api-schema": "^2.0.103",
29
+ "tango-api-schema": "^2.0.113",
30
30
  "tango-app-api-middleware": "^1.0.73-test",
31
31
  "winston": "^3.12.0",
32
32
  "winston-daily-rotate-file": "^5.0.0"
@@ -187,7 +187,6 @@ export async function installationCard( req, res ) {
187
187
  } );
188
188
  let installedCount = await countDocumentsStore( {
189
189
  'clientId': { $in: req.body.clientId },
190
- 'edge.firstFile': true,
191
190
  'status': 'active',
192
191
  'createdAt': { $lte: date.end },
193
192
  } );
@@ -290,7 +289,7 @@ export async function installationCard( req, res ) {
290
289
  res.sendSuccess( {
291
290
  onboardedStoresCount: onboardedCount,
292
291
  inactiveStoresCount: deactiveCount,
293
- installedStoresCount: installedCount,
292
+ installedStoresCount: installedCount-yettoInstallCount.length,
294
293
  yettoInstallCount: yettoInstallCount.length,
295
294
  installFailedCount: installFailedCount.length,
296
295
  infraIssues: response,
@@ -547,7 +546,6 @@ export async function InstallationIssuesTable( req, res ) {
547
546
  $and: [
548
547
  { issueType: 'installation' },
549
548
  { 'status': { $ne: 'closed' } },
550
-
551
549
  { 'basicDetails.clientId': { $in: req.body.clientId } },
552
550
  { createdAt: { $lte: date.end } },
553
551
  ],
@@ -559,6 +557,9 @@ export async function InstallationIssuesTable( req, res ) {
559
557
  if ( req.body.installtionfilterIssue == 'installFailedStores' ) {
560
558
  query.push( { $match: { 'ticketDetails.issueStatus': 'identified' } } );
561
559
  }
560
+ if ( req.body.installtionfilterIssue == 'installedStores' ) {
561
+ query.push( { $match: { 'ticketDetails.issueStatus': 'notidentified' } } );
562
+ }
562
563
  query.push( {
563
564
  $project: {
564
565
  createdAt: 1,
@@ -624,11 +625,16 @@ export async function InstallationIssuesTable( req, res ) {
624
625
  );
625
626
  }
626
627
  if ( req.body.installtionfilterIssue == 'installedStores' ) {
628
+ let pendingstorecount = await aggregateTangoTicket( query );
629
+ let ticketStore = [];
630
+ for ( let store of pendingstorecount ) {
631
+ ticketStore.push( store.storeId );
632
+ }
627
633
  storesQuery.push( {
628
634
  $match: {
629
635
  '$and': [
630
636
  { 'clientId': { $in: req.body.clientId } },
631
- { 'edge.firstFile': true },
637
+ { 'storeId': { $nin: ticketStore } },
632
638
  { 'status': 'active' },
633
639
  { 'createdAt': { $lte: date.end } },
634
640
  ],
@@ -1211,6 +1217,9 @@ export async function ticketCountSplit( req, res ) {
1211
1217
  { issueType: { $in: [ 'highcount', 'lowcount' ] } },
1212
1218
 
1213
1219
  ];
1220
+ if ( req.user.userType === 'client' ) {
1221
+ filter.push( { 'dataMismatch.showToClient': true } );
1222
+ }
1214
1223
  if ( inputData?.issueType && inputData?.issueType?.length > 0 ) {
1215
1224
  filter.push( {
1216
1225
  issueType: { $in: inputData.issueType },
@@ -1285,13 +1294,20 @@ export async function overViewTable( req, res ) {
1285
1294
  {
1286
1295
  'basicDetails.clientId': { $in: inputData.clientId },
1287
1296
  },
1288
-
1289
1297
  ];
1298
+ if ( req.user.userType === 'client' ) {
1299
+ filter.push( { 'dataMismatch.showToClient': true } );
1300
+ }
1290
1301
  if ( inputData?.issueType && inputData?.issueType?.length > 0 ) {
1291
1302
  filter.push( {
1292
1303
  issueType: { $in: inputData.issueType },
1293
1304
  } );
1294
1305
  }
1306
+ if ( inputData?.status && inputData?.status!='' ) {
1307
+ filter.push( {
1308
+ status: inputData?.status,
1309
+ } );
1310
+ }
1295
1311
  const query = [
1296
1312
  {
1297
1313
  $match: {
@@ -1383,6 +1399,10 @@ export async function ticketCount( req, res ) {
1383
1399
  },
1384
1400
 
1385
1401
  ];
1402
+
1403
+ if ( req.user.userType === 'client' ) {
1404
+ filter.push( { 'dataMismatch.showToClient': true } );
1405
+ }
1386
1406
  if ( inputData.clientId && inputData?.clientId?.length > 0 ) {
1387
1407
  filter.push( {
1388
1408
  'basicDetails.clientId': { $in: inputData.clientId },
@@ -1,6 +1,6 @@
1
1
 
2
2
  import { findOneTangoTicket, createTangoTicket, updateOneTangoTicket, aggregateTangoTicket, countDocumentsTangoTicket } from '../services/tangoTicket.service.js';
3
- import { logger, getUTC, appConfig, fileUpload, signedUrl, sendMessageToQueue } from 'tango-app-api-middleware';
3
+ import { logger, getUTC, appConfig, fileUpload, signedUrl, sendMessageToQueue, listFileByPath } from 'tango-app-api-middleware';
4
4
  import dayjs from 'dayjs';
5
5
 
6
6
  export async function createTicket( req, res ) {
@@ -8,8 +8,31 @@ export async function createTicket( req, res ) {
8
8
  let ticketExist = await findOneTangoTicket( { 'issueType': req.body.issueType, 'issueDate': ( new Date( req.body.Date ) ), 'basicDetails.storeId': req.body.storeId } );
9
9
 
10
10
  if ( ticketExist ) {
11
- return res.sendSuccess( 'Ticket Already Exists for the store' );
11
+ return res.sendError( 'Ticket Already Exists for the store', 400 );
12
12
  }
13
+
14
+ if ( req.body.issueType === 'highcount' ) {
15
+ let param = {
16
+ Bucket: appConfig.cloud.aws.bucket.auditInput,
17
+ file_path: `${dayjs( new Date( req.body.Date ) ).format( 'DD-MM-YYYY' )}/${req.body.storeId}/`,
18
+ MaxKeys: 1,
19
+ };
20
+
21
+ param.Bucket = appConfig.cloud.aws.bucket.auditOutput;
22
+
23
+ param.file_path = `${req.body.storeId}/${dayjs( new Date( req.body.Date ) ).format( 'DD-MM-YYYY' )}/`;
24
+
25
+ const auditOutputData = await listFileByPath( param );
26
+
27
+ param.Bucket = appConfig.cloud.aws.bucket.edgeAppSource;
28
+
29
+ const edgeAppSource = await listFileByPath( param );
30
+
31
+ if ( !auditOutputData?.data?.length && !edgeAppSource?.data?.length ) {
32
+ return res.sendError( `No data available for ${req.body.basicDetails.storeName} on ${dayjs( new Date( req.body.Date ) ).format( 'DD-MM-YYYY' )}.`, 400 );
33
+ }
34
+ }
35
+
13
36
  let actionBy = '';
14
37
  if ( req.user.userType == 'tango' ) {
15
38
  actionBy = 'Tango';
@@ -170,6 +193,14 @@ export async function activityList( req, res ) {
170
193
  },
171
194
  );
172
195
 
196
+ if ( req.user.userType === 'client' ) {
197
+ query.forEach( ( e ) => {
198
+ if ( e.$match ) {
199
+ $match.$and.push( { 'dataMismatch.showToClient': true } );
200
+ }
201
+ } );
202
+ }
203
+
173
204
  if ( req.body.filter && req.body.filter !== '' ) {
174
205
  query.push( {
175
206
  $match: {