tango-app-api-analysis-traffic 3.8.7-vms.26 → 3.8.7-vms.28

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-analysis-traffic",
3
- "version": "3.8.7-vms.26",
3
+ "version": "3.8.7-vms.28",
4
4
  "description": "Traffic Analysis",
5
5
  "main": "index.js",
6
6
  "type": "module",
@@ -23,7 +23,7 @@
23
23
  "mongodb": "^6.8.0",
24
24
  "nodemon": "^3.1.4",
25
25
  "swagger-ui-express": "^5.0.1",
26
- "tango-api-schema": "^2.5.2",
26
+ "tango-api-schema": "^2.5.5",
27
27
  "tango-app-api-middleware": "^3.6.5",
28
28
  "winston": "^3.13.1",
29
29
  "winston-daily-rotate-file": "^5.0.0"
@@ -613,7 +613,7 @@ export async function tagTempId( req, res ) {
613
613
  filePath: inputData.filePath,
614
614
  status: inputData?.revopsType == 'non-tagging' ?'':'submitted',
615
615
  description: inputData.comments || '',
616
- isChecked: inputData.isChecked,
616
+ isChecked: null,
617
617
  // Add id to each object in duplicateImage if it exists and is an array
618
618
  duplicateImage: Array.isArray( inputData?.duplicateImage ) ?
619
619
  inputData.duplicateImage.map( ( img ) => ( {
@@ -687,7 +687,7 @@ export async function tagTempId( req, res ) {
687
687
  filePath: inputData.filePath,
688
688
  status: inputData?.revopsType == 'non-tagging' ?'':'submitted',
689
689
  description: inputData.comments || '',
690
- isChecked: inputData.isChecked,
690
+ isChecked: null,
691
691
  createdByEmail: req?.user?.email,
692
692
  createdByUserName: req?.user?.userName,
693
693
  createdByRole: req?.user?.role,
@@ -706,7 +706,7 @@ export async function tagTempId( req, res ) {
706
706
  id: `${inputData?.storeId}_${inputData?.dateString}_${item?.tempId}`,
707
707
  dateString: inputData.dateString,
708
708
  timeRange: item.timeRange,
709
- isChecked: item.isChecked,
709
+ isChecked: null,
710
710
  processType: inputData.processType,
711
711
  revopsType: item.revopsType,
712
712
  entryTime: item.entryTime,
@@ -746,12 +746,20 @@ export async function tagTempId( req, res ) {
746
746
  return { success: false, errors: res1.items };
747
747
  } else {
748
748
  logger.info( { msg: 'res1' } );
749
- return res.sendSuccess( `ID tagged as duplicates` );
749
+ return res.sendSuccess( `ID tagged as Duplicates` );
750
750
  // return { success: true };
751
751
  }
752
752
  }
753
753
  } else {
754
- const message = inputData?.revopsType == 'non-tagging' ? 'ID removed from tagging' :inputData?.revopsType == 'employee' ?'ID tagged as an employee/staff':inputData?.revopsType == 'junk'? 'ID tagged as a junk':'ID tagged as an house keeping';
754
+ // Convert camelCase revopsType to space-separated and capitalize first letter of each word
755
+ function camelCaseToTitle( str ) {
756
+ if ( !str ) return '';
757
+ return str.replace( /([A-Z])/g, ' $1' ).replace( /^./, ( s ) => s.toUpperCase() );
758
+ }
759
+ const titleRevopsType = camelCaseToTitle( inputData?.revopsType );
760
+ const message = inputData?.revopsType == 'non-tagging' ?
761
+ 'ID removed from tagging' :
762
+ `ID tagged as ${titleRevopsType}`;
755
763
  return res.sendSuccess( message );
756
764
  }
757
765
  } catch ( error ) {
@@ -17,7 +17,6 @@ revopRouter
17
17
  .get( '/store-processed-data', isAllowedSessionHandler, validate( storeProcessedDataValid ), storeProcessedData )
18
18
  .get( '/footfall-images', isAllowedSessionHandler, validate( footfallImagesValid ), getTaggingConfig, footFallImages )
19
19
  .post( '/tag-tempId', isAllowedSessionHandler, validate( tagTempIdValid ), deleteTaggedDuplicate, mappingConfig, tagTempId )
20
-
21
20
  .post( '/get-categorized-images', isAllowedSessionHandler, validate( getCategorizedImagesValid ), getCategorizedImages );
22
21
 
23
22
 
@@ -1,6 +1,6 @@
1
1
  import { getOpenSearchCount, logger } from 'tango-app-api-middleware';
2
2
  import { deleteByQuery, getOpenSearchData } from 'tango-app-api-middleware/src/utils/openSearch.js';
3
- import { aggregate, findOne } from '../services/clients.services.js';
3
+ import { aggregate } from '../services/clients.services.js';
4
4
 
5
5
  export async function getTaggingConfig( req, res, next ) {
6
6
  try {
@@ -80,7 +80,7 @@ export async function getTaggingConfig( req, res, next ) {
80
80
 
81
81
 
82
82
  const getData = await aggregate( configQuery );
83
- logger.info( { getData } );
83
+
84
84
  // Convert "taggingLimitation" array (if present) to "config" object with expected key-value pairs
85
85
  let config = {};
86
86
  if ( getData && getData?.length > 0 && Array.isArray( getData?.[0]?.effectiveLimitation?.values ) ) {
@@ -168,9 +168,81 @@ export async function mappingConfig( req, res, next ) {
168
168
  }
169
169
  const getFootfallCount = footfallOutput?.body?.hits?.hits;
170
170
  const footfall = getFootfallCount?.[0]?._source?.footfall_count;
171
+ const clientId = inputData?.storeId?.split( '-' )[0];
172
+ const configQuery = [
173
+ {
174
+ $match: {
175
+ clientId: clientId,
176
+ },
177
+ },
178
+
179
+ // Convert all effectiveFrom to proper Date
180
+ {
181
+ $addFields: {
182
+ taggingLimitationWithDate: {
183
+ $map: {
184
+ input: '$footfallDirectoryConfigs.taggingLimitation',
185
+ as: 'item',
186
+ in: {
187
+ effectiveFrom: { $toDate: '$$item.effectiveFrom' },
188
+ values: '$$item.values',
189
+ },
190
+ },
191
+ },
192
+ },
193
+ },
194
+
195
+ // Filter items <= input date
196
+ {
197
+ $addFields: {
198
+ matchedLimitation: {
199
+ $filter: {
200
+ input: '$taggingLimitationWithDate',
201
+ as: 'item',
202
+ cond: {
203
+ $lte: [
204
+ '$$item.effectiveFrom',
205
+ { $toDate: inputData.dateString },
206
+ ],
207
+ },
208
+ },
209
+ },
210
+ },
211
+ },
212
+
213
+ // Sort DESC and pick ONLY top 1 -> latest effective record
214
+ {
215
+ $addFields: {
216
+ effectiveLimitation: {
217
+ $arrayElemAt: [
218
+ {
219
+ $slice: [
220
+ {
221
+ $sortArray: {
222
+ input: '$matchedLimitation',
223
+ sortBy: { effectiveFrom: -1 },
224
+ },
225
+ },
226
+ 1,
227
+ ],
228
+ },
229
+ 0,
230
+ ],
231
+ },
232
+ },
233
+ },
234
+
235
+ {
236
+ $project: {
237
+ config: 1,
238
+ effectiveLimitation: 1,
239
+ footfallDirectoryConfigs: 1,
240
+ },
241
+ },
242
+ ];
243
+ const getConfig = await aggregate( configQuery );
244
+ const taggingLimitation = getConfig?.[0]?.effectiveLimitation?.values;
171
245
 
172
- const getConfig = await findOne( { clientId: inputData?.storeId?.split( '-' )[0] }, { footfallDirectoryConfigs: 1 } );
173
- const taggingLimitation = getConfig?.footfallDirectoryConfigs?.taggingLimitation;
174
246
  // Find the tagging limitation for the given revopsType
175
247
  let matchedLimitation = null;
176
248
  if ( Array.isArray( taggingLimitation ) ) {