tango-app-api-analysis-traffic 3.8.7-vms.27 → 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.27",
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,
@@ -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 {
@@ -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 ) ) {