tango-app-api-analysis-traffic 3.8.7-vms.34 → 3.8.7-vms.35
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
|
@@ -3,7 +3,7 @@ import { findOnerevopConfig } from '../services/revopConfig.service.js';
|
|
|
3
3
|
import * as clientService from '../services/clients.services.js';
|
|
4
4
|
import { bulkUpdate, insertWithId, scrollResponse, searchOpenSearchData, upsertWithScript } from 'tango-app-api-middleware/src/utils/openSearch.js';
|
|
5
5
|
import { findOneVmsStoreRequest } from '../services/vmsStoreRequest.service.js';
|
|
6
|
-
|
|
6
|
+
import dayjs from 'dayjs';
|
|
7
7
|
// Lamda Service Call //
|
|
8
8
|
async function LamdaServiceCall( url, data ) {
|
|
9
9
|
try {
|
|
@@ -584,12 +584,11 @@ export async function migrateRevopIndex( req, res ) {
|
|
|
584
584
|
export async function expireReviewStatus( req, res ) {
|
|
585
585
|
try {
|
|
586
586
|
const {
|
|
587
|
-
thresholdDate = '2025-12-
|
|
587
|
+
thresholdDate = '2025-12-29',
|
|
588
588
|
batchSize = 500,
|
|
589
589
|
storeId,
|
|
590
590
|
dateString,
|
|
591
591
|
} = req.body;
|
|
592
|
-
logger.info( { inputData: req.body, msg: '........1' } );
|
|
593
592
|
const cutoffDate = new Date( thresholdDate );
|
|
594
593
|
if ( Number.isNaN( cutoffDate.getTime() ) ) {
|
|
595
594
|
return res.sendError( 'Invalid thresholdDate', 400 );
|
|
@@ -632,7 +631,6 @@ export async function expireReviewStatus( req, res ) {
|
|
|
632
631
|
|
|
633
632
|
let firstResponse = await searchOpenSearchData( openSearch.footfallDirectory, query );
|
|
634
633
|
let hitsBatch = firstResponse?.body?.hits?.hits || [];
|
|
635
|
-
logger.info( { hitsBatch } );
|
|
636
634
|
scrollId = firstResponse?.body?._scroll_id;
|
|
637
635
|
|
|
638
636
|
while ( hitsBatch.length > 0 ) {
|
|
@@ -642,25 +640,38 @@ export async function expireReviewStatus( req, res ) {
|
|
|
642
640
|
const src = hit._source || {};
|
|
643
641
|
const mappingInfo = Array.isArray( src.mappingInfo ) ? src.mappingInfo : [];
|
|
644
642
|
let changed = false;
|
|
645
|
-
|
|
643
|
+
let updatedMapping = mappingInfo.map( ( item ) => {
|
|
646
644
|
if ( item?.type === 'review'&& item?.type !== 'Closed' && item?.dueDate ) {
|
|
647
645
|
const due = new Date( item.dueDate );
|
|
648
646
|
logger.info( { due, msg: '..........1', cutoffDate } );
|
|
649
647
|
if ( !Number.isNaN( due.getTime() ) && due < cutoffDate ) {
|
|
650
648
|
changed = true;
|
|
649
|
+
|
|
651
650
|
return { ...item, status: 'Expired' };
|
|
652
651
|
}
|
|
653
652
|
}
|
|
653
|
+
|
|
654
654
|
return item;
|
|
655
655
|
} );
|
|
656
656
|
|
|
657
|
+
if ( changed ) {
|
|
658
|
+
logger.info( { changed, msg: '.......2' } );
|
|
659
|
+
updatedMapping = updatedMapping.map( ( item ) => {
|
|
660
|
+
logger.info( { item, msg: '.......3' } );
|
|
661
|
+
if ( item?.type === 'tagging' ) {
|
|
662
|
+
logger.info( { item: item?.type, msg: '.......4' } );
|
|
663
|
+
return { ...item, status: 'Expired' };
|
|
664
|
+
}
|
|
665
|
+
} );
|
|
666
|
+
}
|
|
667
|
+
|
|
657
668
|
|
|
658
669
|
if ( changed ) {
|
|
659
670
|
const doc = {
|
|
660
671
|
mappingInfo: updatedMapping,
|
|
661
672
|
status: 'Expired',
|
|
662
673
|
};
|
|
663
|
-
|
|
674
|
+
logger.info( { updatedMapping } );
|
|
664
675
|
bulkBody.push(
|
|
665
676
|
{ update: { _index: openSearch.footfallDirectory, _id: hit._id } },
|
|
666
677
|
{ doc: doc, doc_as_upsert: true },
|
|
@@ -1148,8 +1159,15 @@ export async function footFallImages( req, res ) {
|
|
|
1148
1159
|
|
|
1149
1160
|
export async function tagTempId( req, res ) {
|
|
1150
1161
|
try {
|
|
1151
|
-
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1152
1162
|
const inputData = req.body;
|
|
1163
|
+
const today = dayjs();
|
|
1164
|
+
const diff = today.diff( inputData.dateString, 'day' );
|
|
1165
|
+
const taggingDueDate = req?.client?.footfallDirectoryConfigs?.allowTangoReview || 0;
|
|
1166
|
+
if ( diff > taggingDueDate ) {
|
|
1167
|
+
return res.sendError( `Tagging is not allowed for a period exceeding ${taggingDueDate} days`, 400 );
|
|
1168
|
+
}
|
|
1169
|
+
const openSearch = JSON.parse( process.env.OPENSEARCH );
|
|
1170
|
+
|
|
1153
1171
|
const upsertRecord = {
|
|
1154
1172
|
clientId: inputData.storeId.split( '-' )[0],
|
|
1155
1173
|
storeId: inputData.storeId,
|
package/src/dtos/revop.dtos.js
CHANGED
|
@@ -48,18 +48,10 @@ export const tagTempIdSchema = joi.object( {
|
|
|
48
48
|
storeId: joi.string().required(),
|
|
49
49
|
dateString: joi.string().required().custom( ( value, helpers ) => {
|
|
50
50
|
const inputDate = dayjs( value, 'YYYY-MM-DD', true );
|
|
51
|
-
const today = dayjs();
|
|
52
51
|
|
|
53
52
|
if ( !inputDate.isValid() ) {
|
|
54
53
|
return helpers.error( 'any.invalid' );
|
|
55
54
|
}
|
|
56
|
-
|
|
57
|
-
const diff = today.diff( inputDate, 'day' );
|
|
58
|
-
|
|
59
|
-
if ( diff > 3 ) {
|
|
60
|
-
return helpers.message( 'Tagging is not allowed for a period exceeding 3 days' );
|
|
61
|
-
}
|
|
62
|
-
|
|
63
55
|
return value;
|
|
64
56
|
} ), // yyyy-mm-dd
|
|
65
57
|
tempId: joi.number().required(),
|
|
@@ -241,6 +241,7 @@ export async function mappingConfig( req, res, next ) {
|
|
|
241
241
|
},
|
|
242
242
|
];
|
|
243
243
|
const getConfig = await aggregate( configQuery );
|
|
244
|
+
req.client = getConfig[0];
|
|
244
245
|
const taggingLimitation = getConfig?.[0]?.effectiveLimitation?.values;
|
|
245
246
|
|
|
246
247
|
// Find the tagging limitation for the given revopsType
|