tango-app-api-infra 3.0.112-dev → 3.0.113-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.112-dev",
3
+ "version": "3.0.113-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -27,7 +27,7 @@
27
27
  "nodemon": "^3.1.0",
28
28
  "swagger-ui-express": "^5.0.0",
29
29
  "tango-api-schema": "^2.0.115",
30
- "tango-app-api-middleware": "^3.1.19",
30
+ "tango-app-api-middleware": "^3.1.26",
31
31
  "winston": "^3.12.0",
32
32
  "winston-daily-rotate-file": "^5.0.0"
33
33
  },
@@ -1,5 +1,5 @@
1
1
 
2
- import { findOneTangoTicket, createTangoTicket, updateOneTangoTicket, aggregateTangoTicket, countDocumentsTangoTicket } from '../services/tangoTicket.service.js';
2
+ import { findOneTangoTicket, createTangoTicket, updateOneTangoTicket, aggregateTangoTicket, countDocumentsTangoTicket, findTangoTicket } from '../services/tangoTicket.service.js';
3
3
  import { logger, getUTC, fileUpload, signedUrl, sendMessageToQueue, listFileByPath } from 'tango-app-api-middleware';
4
4
  import dayjs from 'dayjs';
5
5
 
@@ -11,6 +11,25 @@ export async function createTicket( req, res ) {
11
11
  return res.sendError( 'Ticket Already Exists for the store', 400 );
12
12
  }
13
13
 
14
+ let date = await getUTC( new Date( ), new Date( ) );
15
+
16
+ let clientTickets = await findTangoTicket(
17
+ {
18
+ $and: [
19
+ { 'basicDetails.clientId': req.body.basicDetails.clientId },
20
+ { issueType: { $in: [ 'lowcount', 'highcount' ] } },
21
+ { createdAt: { $gte: date.start } },
22
+ { createdAt: { $lte: date.end } },
23
+ ],
24
+ },
25
+ );
26
+
27
+
28
+ if ( clientTickets.length > 10 ) {
29
+ return res.sendError( 'Ticket limit exceeded for the day', 400 );
30
+ }
31
+
32
+
14
33
  let param = {
15
34
  Bucket: JSON.parse( process.env.BUCKET ).auditInput,
16
35
  file_path: `${dayjs( new Date( req.body.Date ) ).format( 'DD-MM-YYYY' )}/${req.body.storeId}/`,
@@ -200,7 +219,7 @@ export async function activityList( req, res ) {
200
219
  if ( req.user.userType === 'client' ) {
201
220
  query.forEach( ( e ) => {
202
221
  if ( e.$match ) {
203
- $match.$and.push( { 'dataMismatch.showToClient': true } );
222
+ e.$match.$and.push( { 'dataMismatch.showToClient': true } );
204
223
  }
205
224
  } );
206
225
  }
@@ -961,6 +961,7 @@ export async function allCounts( req, res ) {
961
961
  datamismatchCount: {
962
962
  $cond: [ { $or: [ { $eq: [ '$issueType', 'highcount' ] }, { $eq: [ '$issueType', 'lowcount' ] } ] }, 1, 0,
963
963
  ],
964
+
964
965
  },
965
966
  matCount: {
966
967
  $cond: [ { $and: [ { $eq: [ '$issueType', 'mat' ] } ] }, 1, 0,
@@ -980,6 +981,28 @@ export async function allCounts( req, res ) {
980
981
  },
981
982
  },
982
983
  ];
984
+
985
+ if ( req.user.userType === 'client' ) {
986
+ countQuery.forEach( ( item ) => {
987
+ if ( item.$project ) {
988
+ item.$project.datamismatchCount.$cond = [
989
+ {
990
+ $and: [
991
+ {
992
+ $or: [
993
+ { $eq: [ '$issueType', 'highcount' ] },
994
+ { $eq: [ '$issueType', 'lowcount' ] },
995
+ ],
996
+ },
997
+ { $eq: [ '$dataMismatch.showToClient', true ] },
998
+ ],
999
+ },
1000
+ 1,
1001
+ 0,
1002
+ ];
1003
+ }
1004
+ } );
1005
+ }
983
1006
  let result = await aggregateTangoTicket( countQuery );
984
1007
  res.sendSuccess( result );
985
1008
  } catch ( error ) {
@@ -1775,6 +1798,10 @@ export async function dataMismatchTable( req, res ) {
1775
1798
  },
1776
1799
 
1777
1800
  ];
1801
+
1802
+ if ( req.user.userType === 'client' ) {
1803
+ countFilter.push( { 'dataMismatch.showToClient': true } );
1804
+ }
1778
1805
  if ( inputData.clientId && inputData?.clientId?.length > 0 ) {
1779
1806
  countFilter.push( {
1780
1807
  'basicDetails.clientId': { $in: inputData.clientId },
@@ -1836,6 +1863,10 @@ export async function dataMismatchTable( req, res ) {
1836
1863
  { 'basicDetails.clientId': { $in: inputData.clientId } },
1837
1864
  { issueType: { $in: [ 'highcount', 'lowcount' ] } },
1838
1865
  ];
1866
+
1867
+ if ( req.user.userType === 'client' ) {
1868
+ filter.push( { 'dataMismatch.showToClient': true } );
1869
+ }
1839
1870
  const query = [
1840
1871
  {
1841
1872
  $match: {
@@ -401,7 +401,7 @@ export async function edgeAppLogTable( req, res ) {
401
401
  if ( req.body.export ) {
402
402
  const exportData = timeSlots.map( ( element ) => ( {
403
403
  'Time Stamp': `${element.startTime}-${element.endTime}`,
404
- 'Downtime': element.downtime +'Mins',
404
+ 'Downtime': element.downtime?element.downtime +' Mins':'--',
405
405
  'Avg Internet Speed': element.Internetspeed,
406
406
  'Files Generated': element.files_generated,
407
407
  'Files Pushed': element.files_pushed,
@@ -802,11 +802,11 @@ export async function pendingTicket( req, res ) {
802
802
  ],
803
803
  },
804
804
  datamismatchCount: {
805
- $cond: [ { $and: [ { $or: [ { $eq: [ '$issueType', 'highcount' ] }, { $eq: [ '$issueType', 'lowcount' ] } ] }, { $eq: [ '$status', 'closed' ] } ] }, 1, 0,
805
+ $cond: [ { $and: [ { $or: [ { $eq: [ '$issueType', 'highcount' ] }, { $eq: [ '$issueType', 'lowcount' ] } ] }, { $ne: [ '$status', 'closed' ] } ] }, 1, 0,
806
806
  ],
807
807
  },
808
808
  matCount: {
809
- $cond: [ { $and: [ { $eq: [ '$issueType', 'mat' ] }, { $eq: [ '$status', 'open' ] } ] }, 1, 0,
809
+ $cond: [ { $and: [ { $eq: [ '$issueType', 'mat' ] }, { $ne: [ '$status', 'closed' ] } ] }, 1, 0,
810
810
  ],
811
811
  },
812
812
  },