tango-app-api-analysis-traffic 3.8.7-vms.24 → 3.8.7-vms.25
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,24 +9,45 @@ export async function getTaggingConfig( req, res, next ) {
|
|
|
9
9
|
const configQuery = [
|
|
10
10
|
{
|
|
11
11
|
$match: {
|
|
12
|
-
clientId
|
|
12
|
+
clientId,
|
|
13
13
|
},
|
|
14
14
|
},
|
|
15
15
|
|
|
16
|
-
//
|
|
16
|
+
// Convert all effectiveFrom to proper Date
|
|
17
|
+
{
|
|
18
|
+
$addFields: {
|
|
19
|
+
taggingLimitationWithDate: {
|
|
20
|
+
$map: {
|
|
21
|
+
input: '$footfallDirectoryConfigs.taggingLimitation',
|
|
22
|
+
as: 'item',
|
|
23
|
+
in: {
|
|
24
|
+
effectiveFrom: { $toDate: '$$item.effectiveFrom' },
|
|
25
|
+
values: '$$item.values',
|
|
26
|
+
},
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
},
|
|
30
|
+
},
|
|
31
|
+
|
|
32
|
+
// Filter items <= input date
|
|
17
33
|
{
|
|
18
34
|
$addFields: {
|
|
19
35
|
matchedLimitation: {
|
|
20
36
|
$filter: {
|
|
21
|
-
input: '$
|
|
37
|
+
input: '$taggingLimitationWithDate',
|
|
22
38
|
as: 'item',
|
|
23
|
-
cond: {
|
|
39
|
+
cond: {
|
|
40
|
+
$lte: [
|
|
41
|
+
'$$item.effectiveFrom',
|
|
42
|
+
{ $toDate: inputData.dateString },
|
|
43
|
+
],
|
|
44
|
+
},
|
|
24
45
|
},
|
|
25
46
|
},
|
|
26
47
|
},
|
|
27
48
|
},
|
|
28
49
|
|
|
29
|
-
//
|
|
50
|
+
// Sort DESC and pick ONLY top 1 -> latest effective record
|
|
30
51
|
{
|
|
31
52
|
$addFields: {
|
|
32
53
|
effectiveLimitation: {
|
|
@@ -48,24 +69,10 @@ export async function getTaggingConfig( req, res, next ) {
|
|
|
48
69
|
},
|
|
49
70
|
},
|
|
50
71
|
|
|
51
|
-
// Remove originals before final merge
|
|
52
|
-
{
|
|
53
|
-
$project: {
|
|
54
|
-
'config.taggingLimitation': 0,
|
|
55
|
-
'matchedLimitation': 0,
|
|
56
|
-
},
|
|
57
|
-
},
|
|
58
|
-
|
|
59
|
-
// Attach effective limitation INSIDE config
|
|
60
|
-
{
|
|
61
|
-
$addFields: {
|
|
62
|
-
'config.effectiveLimitation': '$effectiveLimitation',
|
|
63
|
-
},
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
// Remove temporary field
|
|
67
72
|
{
|
|
68
73
|
$project: {
|
|
74
|
+
config: 1,
|
|
75
|
+
effectiveLimitation: 1,
|
|
69
76
|
footfallDirectoryConfigs: 1,
|
|
70
77
|
},
|
|
71
78
|
},
|
|
@@ -73,9 +80,10 @@ export async function getTaggingConfig( req, res, next ) {
|
|
|
73
80
|
|
|
74
81
|
|
|
75
82
|
const getData = await aggregate( configQuery );
|
|
83
|
+
logger.info( { getData } );
|
|
76
84
|
// Convert "taggingLimitation" array (if present) to "config" object with expected key-value pairs
|
|
77
85
|
let config = {};
|
|
78
|
-
if ( getData && getData?.length > 0 && Array.isArray( getData?.[0]?.
|
|
86
|
+
if ( getData && getData?.length > 0 && Array.isArray( getData?.[0]?.effectiveLimitation?.values ) ) {
|
|
79
87
|
for ( const item of getData?.[0]?.footfallDirectoryConfigs?.taggingLimitation?.[0]?.values ) {
|
|
80
88
|
if ( item && item.type && typeof item.value !== 'undefined' && item.unit ) {
|
|
81
89
|
config[item.type] = `${item.value}${item.unit}`;
|
|
@@ -85,7 +93,7 @@ export async function getTaggingConfig( req, res, next ) {
|
|
|
85
93
|
// getData[0].footfallDirectoryConfigs.taggingLimitation = [];
|
|
86
94
|
getData[0].footfallDirectoryConfigs.config = config;
|
|
87
95
|
|
|
88
|
-
getData[0].footfallDirectoryConfigs.taggingLimitation = getData
|
|
96
|
+
getData[0].footfallDirectoryConfigs.taggingLimitation = getData?.[0]?.effectiveLimitation?.values;
|
|
89
97
|
req.store = getData[0];
|
|
90
98
|
next();
|
|
91
99
|
} catch ( error ) {
|