tango-app-api-infra 3.9.5-vms.58 → 3.9.5-vms.59
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
|
@@ -410,9 +410,9 @@ export async function ticketCreation( req, res, next ) {
|
|
|
410
410
|
|
|
411
411
|
const revopTaggingData = await getOpenSearchData( openSearch.revop, taggingData );
|
|
412
412
|
const taggingImages = revopTaggingData?.body?.hits?.hits;
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
413
|
+
if ( !taggingImages || taggingImages?.length == 0 ) {
|
|
414
|
+
return res.sendError( 'You don’t have any tagged images right now', 400 );
|
|
415
|
+
}
|
|
416
416
|
const formattedTaggingData = formatRevopTaggingHits( taggingImages );
|
|
417
417
|
|
|
418
418
|
const record = {
|
|
@@ -567,17 +567,22 @@ export async function ticketCreation( req, res, next ) {
|
|
|
567
567
|
let createdOn = dayjs().format( 'DD MMM YYYY' );
|
|
568
568
|
let description = `Created on ${createdOn}`;
|
|
569
569
|
let Data = {
|
|
570
|
-
|
|
571
|
-
|
|
570
|
+
'title': title,
|
|
571
|
+
'body': description,
|
|
572
|
+
'type': 'create',
|
|
573
|
+
'date': record.dateString,
|
|
574
|
+
'storeId': record.storeId,
|
|
575
|
+
'clientId': record.clientId,
|
|
576
|
+
'ticketId': record.ticketId,
|
|
572
577
|
};
|
|
573
578
|
|
|
574
579
|
const ticketsFeature = userData?.rolespermission?.some( ( f ) => f.featureName === 'FootfallDirectory' && ( f.modules.find( ( m ) => m.name == 'reviewer' && ( m.isAdd == true || m.isEdit == true ) ) ) );
|
|
575
580
|
|
|
576
581
|
if ( ticketsFeature ) {
|
|
577
|
-
let notifyuser = await getAssinedStore( userData, req.body.storeId
|
|
582
|
+
let notifyuser = await getAssinedStore( userData, req.body.storeId );
|
|
578
583
|
if ( userData && userData.fcmToken && notifyuser ) {
|
|
579
584
|
const fcmToken = userData.fcmToken;
|
|
580
|
-
await sendPushNotification( title, description, fcmToken );
|
|
585
|
+
await sendPushNotification( title, description, fcmToken, Data );
|
|
581
586
|
}
|
|
582
587
|
}
|
|
583
588
|
}
|
|
@@ -587,7 +592,7 @@ export async function ticketCreation( req, res, next ) {
|
|
|
587
592
|
const id = `${inputData.storeId}_${inputData.dateString}_footfall-directory-tagging`;
|
|
588
593
|
const insertResult = await insertWithId( openSearch.footfallDirectory, id, record );
|
|
589
594
|
if ( insertResult && insertResult.statusCode === 201 ) {
|
|
590
|
-
|
|
595
|
+
// After successful ticket creation, update status to "submitted" in revop index for the relevant records
|
|
591
596
|
|
|
592
597
|
|
|
593
598
|
const bulkUpdateBody = taggingImages.map( ( img ) => [
|
|
@@ -625,14 +630,14 @@ export async function ticketCreation( req, res, next ) {
|
|
|
625
630
|
const startDateObj = new Date( currentDateObj );
|
|
626
631
|
|
|
627
632
|
if ( breachDays === 30 ) {
|
|
628
|
-
|
|
633
|
+
// Consider within this month
|
|
629
634
|
startDateObj.setDate( 1 ); // First day of current month
|
|
630
635
|
} else if ( breachDays === 60 ) {
|
|
631
|
-
|
|
636
|
+
// Consider this month and last month
|
|
632
637
|
startDateObj.setMonth( startDateObj.getMonth() - 1 );
|
|
633
638
|
startDateObj.setDate( 1 ); // First day of last month
|
|
634
639
|
} else {
|
|
635
|
-
|
|
640
|
+
// For other values, calculate months from days
|
|
636
641
|
const breachMonths = Math.ceil( breachDays / 30 );
|
|
637
642
|
startDateObj.setMonth( startDateObj.getMonth() - breachMonths + 1 );
|
|
638
643
|
startDateObj.setDate( 1 );
|
|
@@ -680,21 +685,21 @@ export async function ticketCreation( req, res, next ) {
|
|
|
680
685
|
}
|
|
681
686
|
|
|
682
687
|
if ( breachTicketsCount >= breachCount ) {
|
|
683
|
-
|
|
688
|
+
// Calculate remaining future days in the config period
|
|
684
689
|
const futureDates = [];
|
|
685
690
|
|
|
686
691
|
// Calculate end date of config period
|
|
687
692
|
const configEndDateObj = new Date( currentDateObj );
|
|
688
693
|
if ( breachDays === 30 ) {
|
|
689
|
-
|
|
694
|
+
// End of current month
|
|
690
695
|
configEndDateObj.setMonth( configEndDateObj.getMonth() + 1 );
|
|
691
696
|
configEndDateObj.setDate( 0 ); // Last day of current month
|
|
692
697
|
} else if ( breachDays === 60 ) {
|
|
693
|
-
|
|
698
|
+
// End of next month
|
|
694
699
|
configEndDateObj.setMonth( configEndDateObj.getMonth() + 2 );
|
|
695
700
|
configEndDateObj.setDate( 0 ); // Last day of next month
|
|
696
701
|
} else {
|
|
697
|
-
|
|
702
|
+
// For other values, add the remaining days
|
|
698
703
|
const remainingDays = breachDays - ( Math.floor( ( currentDateObj - startDateObj ) / ( 1000 * 60 * 60 * 24 ) ) );
|
|
699
704
|
configEndDateObj.setDate( configEndDateObj.getDate() + remainingDays );
|
|
700
705
|
}
|
|
@@ -723,7 +728,7 @@ export async function ticketCreation( req, res, next ) {
|
|
|
723
728
|
}
|
|
724
729
|
}
|
|
725
730
|
}
|
|
726
|
-
const sqsName =sqs.vmsPickleExtention;
|
|
731
|
+
const sqsName = sqs.vmsPickleExtention;
|
|
727
732
|
const sqsProduceQueue = {
|
|
728
733
|
QueueUrl: `${sqs.url}${sqsName}`,
|
|
729
734
|
MessageBody: JSON.stringify( {
|
|
@@ -1144,9 +1149,9 @@ export async function ticketReview( req, res, next ) {
|
|
|
1144
1149
|
}
|
|
1145
1150
|
|
|
1146
1151
|
let checkreview = getConfig.footfallDirectoryConfigs.revision.filter( ( data ) => data.actionType === 'reviewer' && data.isChecked === true );
|
|
1147
|
-
let checkapprove = getConfig.footfallDirectoryConfigs.revision.filter( ( data ) => data.actionType === 'approver' && data.isChecked === true );
|
|
1148
1152
|
|
|
1149
|
-
|
|
1153
|
+
|
|
1154
|
+
if ( checkreview.length > 0 ) {
|
|
1150
1155
|
let userQuery = [
|
|
1151
1156
|
{
|
|
1152
1157
|
$match: {
|
|
@@ -1156,6 +1161,7 @@ export async function ticketReview( req, res, next ) {
|
|
|
1156
1161
|
},
|
|
1157
1162
|
];
|
|
1158
1163
|
let finduserList = await aggregateUser( userQuery );
|
|
1164
|
+
console.log( '🚀 ~ ticketReview ~ finduserList:', finduserList );
|
|
1159
1165
|
|
|
1160
1166
|
// return;
|
|
1161
1167
|
for ( let userData of finduserList ) {
|
|
@@ -1164,16 +1170,21 @@ export async function ticketReview( req, res, next ) {
|
|
|
1164
1170
|
let description = `Created on ${createdOn}`;
|
|
1165
1171
|
|
|
1166
1172
|
let Data = {
|
|
1167
|
-
|
|
1168
|
-
|
|
1173
|
+
'title': title,
|
|
1174
|
+
'body': description,
|
|
1175
|
+
'type': 'review',
|
|
1176
|
+
'date': record.dateString,
|
|
1177
|
+
'storeId': record.storeId,
|
|
1178
|
+
'clientId': record.clientId,
|
|
1179
|
+
'ticketId': record.ticketId,
|
|
1169
1180
|
};
|
|
1170
1181
|
const ticketsFeature = userData?.rolespermission?.some( ( f ) => f.featureName === 'FootfallDirectory' && ( f.modules.find( ( m ) => m.name == 'reviewer' && ( m.isAdd == true || m.isEdit == true ) ) ) );
|
|
1171
1182
|
|
|
1172
1183
|
if ( ticketsFeature ) {
|
|
1173
|
-
let notifyuser = await getAssinedStore( userData, req.body.storeId
|
|
1184
|
+
let notifyuser = await getAssinedStore( userData, req.body.storeId );
|
|
1174
1185
|
if ( userData && userData.fcmToken && notifyuser ) {
|
|
1175
1186
|
const fcmToken = userData.fcmToken;
|
|
1176
|
-
await sendPushNotification( title, description, fcmToken );
|
|
1187
|
+
await sendPushNotification( title, description, fcmToken, Data );
|
|
1177
1188
|
}
|
|
1178
1189
|
}
|
|
1179
1190
|
}
|
|
@@ -1189,7 +1200,7 @@ export async function ticketReview( req, res, next ) {
|
|
|
1189
1200
|
}
|
|
1190
1201
|
} catch ( error ) {
|
|
1191
1202
|
const err = error.message || 'Internal Server Error';
|
|
1192
|
-
logger.error( { error: err, funtion: '
|
|
1203
|
+
logger.error( { error: err, funtion: 'ticketreview' } );
|
|
1193
1204
|
return res.sendError( err, 500 );
|
|
1194
1205
|
}
|
|
1195
1206
|
}
|
|
@@ -1635,12 +1646,11 @@ export async function ticketApprove( req, res, next ) {
|
|
|
1635
1646
|
},
|
|
1636
1647
|
);
|
|
1637
1648
|
}
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
let checkreview = getConfig.footfallDirectoryConfigs.revision.filter( ( data ) => data.actionType === 'reviewer' && data.isChecked === true );
|
|
1649
|
+
console.log( req.body, getConfig.footfallDirectoryConfigs.revision );
|
|
1641
1650
|
let checkapprove = getConfig.footfallDirectoryConfigs.revision.filter( ( data ) => data.actionType === 'approver' && data.isChecked === true );
|
|
1642
1651
|
|
|
1643
|
-
|
|
1652
|
+
|
|
1653
|
+
if ( checkapprove.length > 0 ) {
|
|
1644
1654
|
let userQuery = [
|
|
1645
1655
|
{
|
|
1646
1656
|
$match: {
|
|
@@ -1650,24 +1660,30 @@ export async function ticketApprove( req, res, next ) {
|
|
|
1650
1660
|
},
|
|
1651
1661
|
];
|
|
1652
1662
|
let finduserList = await aggregateUser( userQuery );
|
|
1663
|
+
console.log( '🚀 ~ ticketReview ~ finduserList:', finduserList );
|
|
1653
1664
|
|
|
1654
|
-
// return;
|
|
1655
1665
|
for ( let userData of finduserList ) {
|
|
1656
1666
|
let title = `${getstoreName?.storeName} Have raised a ticket for a Footfall Mismatch`;
|
|
1657
1667
|
let createdOn = dayjs().format( 'DD MMM YYYY' );
|
|
1658
1668
|
let description = `Created on ${createdOn}`;
|
|
1659
|
-
|
|
1669
|
+
console.log( '🚀 ~ ticketCreation ~ userData.role:', userData.email );
|
|
1660
1670
|
let Data = {
|
|
1661
|
-
|
|
1662
|
-
|
|
1671
|
+
'title': title,
|
|
1672
|
+
'body': description,
|
|
1673
|
+
'type': 'approve',
|
|
1674
|
+
'date': record.dateString,
|
|
1675
|
+
'storeId': record.storeId,
|
|
1676
|
+
'clientId': record.clientId,
|
|
1677
|
+
'ticketId': record.ticketId,
|
|
1663
1678
|
};
|
|
1664
|
-
const ticketsFeature = userData?.rolespermission?.some( ( f ) => f.featureName === 'FootfallDirectory' && ( f.modules.find( ( m ) => m.name == 'approver' && ( m.isAdd == true || m.isEdit == true ) ) ) );
|
|
1665
1679
|
|
|
1680
|
+
const ticketsFeature = userData?.rolespermission?.some( ( f ) => f.featureName === 'FootfallDirectory' && ( f.modules.find( ( m ) => m.name == 'approver' && ( m.isAdd == true || m.isEdit == true ) ) ) );
|
|
1681
|
+
console.log( ticketsFeature );
|
|
1666
1682
|
if ( ticketsFeature ) {
|
|
1667
|
-
let notifyuser = await getAssinedStore( userData, req.body.storeId
|
|
1683
|
+
let notifyuser = await getAssinedStore( userData, req.body.storeId );
|
|
1668
1684
|
if ( userData && userData.fcmToken && notifyuser ) {
|
|
1669
1685
|
const fcmToken = userData.fcmToken;
|
|
1670
|
-
await sendPushNotification( title, description, fcmToken );
|
|
1686
|
+
await sendPushNotification( title, description, fcmToken, Data );
|
|
1671
1687
|
}
|
|
1672
1688
|
}
|
|
1673
1689
|
}
|