tango-app-api-infra 3.0.75-dev → 3.0.77-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.75-dev",
3
+ "version": "3.0.77-dev",
4
4
  "description": "infra",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -25,8 +25,8 @@
25
25
  "joi-to-swagger": "^6.2.0",
26
26
  "mongodb": "^6.4.0",
27
27
  "nodemon": "^3.1.0",
28
- "tango-api-schema": "^2.0.100",
29
28
  "swagger-ui-express": "^5.0.0",
29
+ "tango-api-schema": "^2.0.101",
30
30
  "tango-app-api-middleware": "^1.0.68-dev",
31
31
  "winston": "^3.12.0",
32
32
  "winston-daily-rotate-file": "^5.0.0"
@@ -1,6 +1,8 @@
1
1
 
2
2
  import { findOneTangoTicket, createTangoTicket, updateOneTangoTicket, aggregateTangoTicket, countDocumentsTangoTicket } from '../services/tangoTicket.service.js';
3
- import { logger, getUTC, appConfig, fileUpload, signedUrl } from 'tango-app-api-middleware';
3
+ import { logger, getUTC, appConfig, fileUpload, signedUrl, sendMessageToQueue } from 'tango-app-api-middleware';
4
+ import dayjs from 'dayjs';
5
+
4
6
  export async function createTicket( req, res ) {
5
7
  try {
6
8
  let ticketExist = await findOneTangoTicket( { 'issueType': req.body.issueType, 'issueDate': ( new Date( req.body.Date ) ), 'basicDetails.storeId': req.body.storeId } );
@@ -49,6 +51,17 @@ export async function createTicket( req, res ) {
49
51
  attachments: [ getObject ],
50
52
  } ];
51
53
  await updateOneTangoTicket( { ticketId: create.ticketId }, { ticketActivity: req.body.ticketActivity } );
54
+
55
+ const ticket = await findOneTangoTicket( { ticketId: req.body.ticketId }, { 'issueDate': 1, 'basicDetails': 1, 'issueType': 1, 'dataMismatch.contactEmail': 1, '_id': 0 } );
56
+
57
+ const obj = {
58
+ storeId: ticket.basicDetails.storeId,
59
+ issueDate: dayjs( ticket.issueDate ).format( 'DD-MM-YYYY' ),
60
+ };
61
+
62
+ if ( req.body.issueType === 'highcount' ) {
63
+ await sendMessageToQueue( `${appConfig.cloud.aws.sqs.url}${appConfig.cloud.aws.sqs.highcountTopic}`, JSON.stringify( obj ) );
64
+ }
52
65
  if ( create ) {
53
66
  res.sendSuccess( 'Ticket Created Successfully' );
54
67
  }
@@ -777,9 +777,41 @@ export async function getInfraIssues( req, res ) {
777
777
  },
778
778
  },
779
779
  ];
780
+
781
+ const highCountQuery =[
782
+ {
783
+ $match: {
784
+ $and: [
785
+ { 'basicDetails.storeId': inputData.storeId },
786
+ { issueType: { $in: [ 'highcount', 'lowcount' ] } },
787
+
788
+ ],
789
+ },
790
+ },
791
+ {
792
+ $group: {
793
+ _id: null,
794
+ total: { $sum: 1 },
795
+ successRate: { $avg: '$successPercentage' },
796
+ },
797
+ },
798
+ {
799
+ $project: {
800
+ _id: 0,
801
+ total: 1,
802
+ successRate: 1,
803
+ },
804
+ },
805
+ ];
806
+ const defaultValue= {
807
+ total: 0,
808
+ successRate: 0,
809
+ };
810
+ const getHighCountTicket = await aggregateTangoTicket( highCountQuery );
811
+ logger.info( { getHighCountTicket: getHighCountTicket } );
780
812
  const camera = await aggregateCamera( camQuery );
781
813
  logger.info( { message: camera } );
782
- return res.sendSuccess( { result: mergeValue, streams: camera } );
814
+ return res.sendSuccess( { result: mergeValue, streams: camera, highCountTicketDetails: getHighCountTicket[0] || defaultValue } );
783
815
  } catch ( error ) {
784
816
  logger.error( { error: error, function: 'getInfraIssues' } );
785
817
  return res.sendError( error, 500 );