tango-app-api-infra 3.1.16 → 3.1.18

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.
@@ -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,18 @@ 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( { 'basicDetails.clientId': req.body.basicDetails.clientId, 'createdAt': {
17
+ $gte: date.start,
18
+ $lte: date.end,
19
+ } } );
20
+
21
+ if ( clientTickets.length > 10 ) {
22
+ return res.sendError( 'Ticket limit exceeded for the day', 400 );
23
+ }
24
+
25
+
14
26
  let param = {
15
27
  Bucket: JSON.parse( process.env.BUCKET ).auditInput,
16
28
  file_path: `${dayjs( new Date( req.body.Date ) ).format( 'DD-MM-YYYY' )}/${req.body.storeId}/`,
@@ -19,7 +19,9 @@ export async function createTicket( req, res ) {
19
19
  try {
20
20
  req.body.issueDate = new Date( req.body.Date );
21
21
  if ( req.body.issueType == 'infra' ) {
22
- req.body.ticketId = 'TE_INF_' + new Date().valueOf();
22
+ if ( !req.body.ticketId ) {
23
+ req.body.ticketId = 'TE_INF_' + new Date().valueOf();
24
+ }
23
25
  req.body.ticketActivity = [ {
24
26
  actionType: 'defaultInfra',
25
27
  timeStamp: new Date(),
@@ -28,7 +30,7 @@ export async function createTicket( req, res ) {
28
30
  } ];
29
31
  let ticketExists= await findOneTangoTicket( { ticketId: req.body.ticketId } );
30
32
  if ( ticketExists ) {
31
- res.status( 200 ).send( { storeId: req.body.storeId } );
33
+ return res.status( 200 ).send( { message: 'ticketId Exists', storeId: req.body.storeId } );
32
34
  }
33
35
  }
34
36
  if ( req.body.issueType == 'installation' ) {
@@ -70,7 +72,7 @@ export async function createTicket( req, res ) {
70
72
  downtimetotal = 0;
71
73
  }
72
74
 
73
-
75
+ console.log( req.body );
74
76
  let create = await createTangoTicket( req.body );
75
77
  let Timestamp = dayjs().format( 'YYYY-MM-DD HH:mm' );
76
78
  const attachments = null;
@@ -237,7 +239,16 @@ export async function updateTicketIssue( req, res ) {
237
239
  'status': 'inprogress',
238
240
  };
239
241
  }
242
+ if ( req.body.issueType === 'infra' ) {
243
+ let client = await findOneClient( { clientId: req.body.basicDetails.clientId } );
244
+ let refreshdate = dayjs().add( client.ticketConfigs.refreshAlert, 'days' );
245
+ console.log( new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ) );
246
+ query = { ...query, 'ticketDetails.ticketRefreshTime': new Date( dayjs( refreshdate ).format( 'YYYY-MM-DD' ) ),
247
+ };
248
+ }
249
+ console.log( query );
240
250
  let updateTicket = await updateOneTangoTicket( { ticketId: req.body.ticketId }, query );
251
+
241
252
  if ( req.body.ticketDetails.ticketType === 'refreshticket' ) {
242
253
  await updateOneTangoTicket( { ticketId: req.body.ticketId }, { 'ticketDetails.refreshTicketStatus': 'identified' } );
243
254
  }
@@ -156,7 +156,7 @@ export async function updateRefreshTicket( req, res ) {
156
156
  try {
157
157
  for ( let ticket of req.body.TicketList ) {
158
158
  let getTicket = await findOneTangoTicket( { ticketId: ticket.ticketId } );
159
- await updateOneTangoTicket( { ticketId: ticket.ticketId }, { 'ticketDetails.ticketType': 'refreshticket' } );
159
+ await updateOneTangoTicket( { ticketId: ticket.ticketId }, { 'ticketDetails.ticketType': 'refreshticket', 'ticketDetails.refreshTicketStatus': 'notidentified' } );
160
160
  await updateOneTangoTicketunset( { ticketId: ticket.ticketId }, { 'ticketDetails.addressingUser': 1 } );
161
161
  let downTimeQuery = {
162
162
  'size': 1,
@@ -901,7 +901,7 @@ export async function edgeApplogsCheck( req, res ) {
901
901
  edgelog: findissue,
902
902
  storeId: ticket.basicDetails.storeId,
903
903
  primary: 'System Issues',
904
- secondary: [ 'Malware or Viruses' ],
904
+ secondary: [ 'Antivirus blockages' ],
905
905
  };
906
906
  updateIssue( findissueEdgeApp );
907
907
  finalresult.push( findissueEdgeApp );
@@ -920,7 +920,7 @@ export async function edgeApplogsCheck( req, res ) {
920
920
  storeId: ticket.basicDetails.storeId,
921
921
  edgelog: findissue.edgelog.data,
922
922
  primary: 'Camera Issues',
923
- secondary: [ 'Camera Not working/RTSP port not working' ],
923
+ secondary: [ 'Camera not working' ],
924
924
  };
925
925
  updateIssue( findissueEdgeApp );
926
926
  finalresult.push( findissueEdgeApp );
@@ -951,7 +951,7 @@ export async function edgeApplogsCheck( req, res ) {
951
951
  edgelog: findissue,
952
952
  storeId: ticket.basicDetails.storeId,
953
953
  primary: 'Internet Issues',
954
- secondary: [ 'Slow Internet Speed' ],
954
+ secondary: [ 'Internet slow' ],
955
955
  };
956
956
  updateIssue( findissueEdgeApp );
957
957
  finalresult.push( findissueEdgeApp );