tango-app-api-infra 3.9.5-vms.60 → 3.9.5-vms.61
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
|
@@ -9,6 +9,8 @@ import { findteams } from '../services/teams.service.js';
|
|
|
9
9
|
import { findcluster } from '../services/cluster.service.js';
|
|
10
10
|
import { sendPushNotification } from 'tango-app-api-middleware';
|
|
11
11
|
import dayjs from 'dayjs';
|
|
12
|
+
import { sendSqsMessage } from '../controllers/footfallDirectory.controllers.js';
|
|
13
|
+
import { countDocumnetsCamera } from '../services/camera.service.js';
|
|
12
14
|
// import utc from 'dayjs/plugin/utc.js';
|
|
13
15
|
// import timezone from 'dayjs/plugin/timezone.js';
|
|
14
16
|
|
|
@@ -232,6 +234,7 @@ export async function ticketCreation( req, res, next ) {
|
|
|
232
234
|
try {
|
|
233
235
|
const inputData = req.body;
|
|
234
236
|
const sqs = JSON.parse( process.env.SQS );
|
|
237
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
235
238
|
if ( inputData?.type !== 'create' ) {
|
|
236
239
|
return next();
|
|
237
240
|
}
|
|
@@ -250,7 +253,6 @@ export async function ticketCreation( req, res, next ) {
|
|
|
250
253
|
}
|
|
251
254
|
|
|
252
255
|
// get the footfall count from opensearch
|
|
253
|
-
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
254
256
|
const dateString = `${inputData.storeId}_${inputData.dateString}`;
|
|
255
257
|
const getQuery = {
|
|
256
258
|
query: {
|
|
@@ -604,7 +606,93 @@ export async function ticketCreation( req, res, next ) {
|
|
|
604
606
|
await bulkUpdate( bulkUpdateBody ); // Optionally use a dedicated bulk helper if available
|
|
605
607
|
}
|
|
606
608
|
|
|
609
|
+
if ( record.status = 'Closed' ) {
|
|
610
|
+
const query = {
|
|
611
|
+
storeId: inputData?.storeId,
|
|
612
|
+
isVideoStream: true,
|
|
613
|
+
};
|
|
614
|
+
const getStoreType = await countDocumnetsCamera( query );
|
|
615
|
+
const revopInfoQuery = {
|
|
616
|
+
size: 10000,
|
|
617
|
+
query: {
|
|
618
|
+
bool: {
|
|
619
|
+
must: [
|
|
620
|
+
{
|
|
621
|
+
term: {
|
|
622
|
+
'storeId.keyword': inputData.storeId,
|
|
623
|
+
},
|
|
624
|
+
},
|
|
625
|
+
{
|
|
626
|
+
term: {
|
|
627
|
+
'dateString': inputData.dateString,
|
|
628
|
+
},
|
|
629
|
+
},
|
|
630
|
+
{
|
|
631
|
+
term: {
|
|
632
|
+
'isParent': false,
|
|
633
|
+
},
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
term: {
|
|
637
|
+
isChecked: true,
|
|
638
|
+
},
|
|
639
|
+
},
|
|
640
|
+
],
|
|
641
|
+
},
|
|
642
|
+
},
|
|
643
|
+
_source: [ 'tempId' ],
|
|
607
644
|
|
|
645
|
+
};
|
|
646
|
+
|
|
647
|
+
const revopInfo = await getOpenSearchData( openSearch.revop, revopInfoQuery );
|
|
648
|
+
|
|
649
|
+
// Get all tempIds from revopInfo response
|
|
650
|
+
const tempIds =
|
|
651
|
+
revopInfo?.body?.hits?.hits?.map( ( hit ) => hit?._source?.tempId ).filter( Boolean ) || [];
|
|
652
|
+
// Prepare management eyeZone query based on storeId and dateString
|
|
653
|
+
const managerEyeZoneQuery = {
|
|
654
|
+
size: 1,
|
|
655
|
+
query: {
|
|
656
|
+
bool: {
|
|
657
|
+
must: [
|
|
658
|
+
{
|
|
659
|
+
term: {
|
|
660
|
+
'storeId.keyword': inputData.storeId,
|
|
661
|
+
},
|
|
662
|
+
},
|
|
663
|
+
{
|
|
664
|
+
term: {
|
|
665
|
+
'storeDate': inputData.dateString,
|
|
666
|
+
},
|
|
667
|
+
},
|
|
668
|
+
],
|
|
669
|
+
},
|
|
670
|
+
},
|
|
671
|
+
_source: [ 'originalToTrackerCustomerMapping' ],
|
|
672
|
+
};
|
|
673
|
+
|
|
674
|
+
// Query the managerEyeZone index for the matching document
|
|
675
|
+
const managerEyeZoneResp = await getOpenSearchData( openSearch.managerEyeZone, managerEyeZoneQuery );
|
|
676
|
+
const managerEyeZoneHit = managerEyeZoneResp?.body?.hits?.hits?.[0]?._source;
|
|
677
|
+
// Extract originalToTrackerCustomerMapping if it exists
|
|
678
|
+
const mapping =
|
|
679
|
+
managerEyeZoneHit && managerEyeZoneHit.originalToTrackerCustomerMapping ?
|
|
680
|
+
managerEyeZoneHit.originalToTrackerCustomerMapping :
|
|
681
|
+
{};
|
|
682
|
+
|
|
683
|
+
// If you want to compare or find matching tempIds in the mapping
|
|
684
|
+
// The mapping is { "1": tempId1, ... }, so get values as array of tempIds
|
|
685
|
+
// const managerMappedTempIds = Object.values( mapping );
|
|
686
|
+
|
|
687
|
+
// Find tempIds that exist in both revopInfo results and manager mapping
|
|
688
|
+
const temp = [];
|
|
689
|
+
tempIds.filter( ( tid ) => mapping[tid] !== null ? temp.push( { tempId: mapping[tid] } ) :'' );
|
|
690
|
+
const isSendMessge = await sendSqsMessage( inputData, temp, getStoreType, inputData.storeId );
|
|
691
|
+
if ( isSendMessge == true ) {
|
|
692
|
+
logger.info( '....1' );
|
|
693
|
+
// return true; // res.sendSuccess( 'Ticket has been updated successfully' );
|
|
694
|
+
} // Example: log or use these tempIds for further logic
|
|
695
|
+
}
|
|
608
696
|
// Check if ticketCount exceeds breach limit within config months and revised footfall percentage > config accuracy
|
|
609
697
|
|
|
610
698
|
if ( req.accuracyBreach && req.accuracyBreach.ticketCount && req.accuracyBreach.days && req.accuracyBreach.accuracy ) {
|
|
@@ -754,7 +842,7 @@ export async function ticketCreation( req, res, next ) {
|
|
|
754
842
|
}
|
|
755
843
|
} catch ( error ) {
|
|
756
844
|
const err = error.message || 'Internal Server Error';
|
|
757
|
-
logger.error( { error:
|
|
845
|
+
logger.error( { error: error, funtion: 'ticketCreation' } );
|
|
758
846
|
return res.sendError( err, 500 );
|
|
759
847
|
}
|
|
760
848
|
}
|