tango-app-api-audit 3.6.53 → 3.6.54
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
|
@@ -933,7 +933,8 @@ export async function getFilterData( msg, user ) {
|
|
|
933
933
|
( item ) =>
|
|
934
934
|
item.temp_ids < 20000 &&
|
|
935
935
|
item.temp_ids > 0 &&
|
|
936
|
-
item.person_status === ''
|
|
936
|
+
item.person_status === '' &&
|
|
937
|
+
item.query_status !== '',
|
|
937
938
|
);
|
|
938
939
|
const finalResult = await filterData.map( ( i ) => {
|
|
939
940
|
return { ...i, img: i.index.concat( '_', i.temp_ids ) };
|
|
@@ -150,13 +150,11 @@ export async function mapCustomer( sourceMappingData, customerData ) {
|
|
|
150
150
|
try {
|
|
151
151
|
const filterCustomerData = await filteredCustomerMap( customerData );
|
|
152
152
|
logger.info( { filterCustomerData: filterCustomerData } );
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
const mappedArrays = await Promise.all( promises );
|
|
159
|
-
return mappedArrays.flat();
|
|
153
|
+
// Build the lookup once, then retag every row in a single pass. This is
|
|
154
|
+
// O(rows + mappedIds) and scales for concurrent submissions, versus the old
|
|
155
|
+
// O(customers x mappedIds x rows) scan that also re-read its own mutations.
|
|
156
|
+
const customerMap = buildCustomerMap( filterCustomerData );
|
|
157
|
+
return mapFunction( sourceMappingData, customerMap );
|
|
160
158
|
} catch ( error ) {
|
|
161
159
|
logger.error( { error: error, type: 'mapCustomer' } );
|
|
162
160
|
return error;
|
|
@@ -167,22 +165,39 @@ const filteredCustomerMap = async ( data ) => {
|
|
|
167
165
|
return data.filter( ( map ) => map.count >= 1 );
|
|
168
166
|
};
|
|
169
167
|
|
|
170
|
-
|
|
168
|
+
// Lookup of original cluster id (child img_name) -> the customer it was tagged
|
|
169
|
+
// into. Last write wins if the same id is referenced by more than one group, so
|
|
170
|
+
// the result is deterministic regardless of customer order.
|
|
171
|
+
const buildCustomerMap = ( filterData ) => {
|
|
172
|
+
const customerMap = new Map();
|
|
171
173
|
for ( const data of filterData ) {
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
}
|
|
174
|
+
if ( !data?.mappedid ) continue;
|
|
175
|
+
for ( const mappedId of data.mappedid ) {
|
|
176
|
+
customerMap.set( mappedId.img_name, {
|
|
177
|
+
parentId: data.img_name,
|
|
178
|
+
demographic: data.demographic || '',
|
|
179
|
+
// The chosen representative (img_name === parent) keeps its query flag so
|
|
180
|
+
// it resurfaces in reaudit; every other merged image is cleared so it does
|
|
181
|
+
// not (query_status is the reaudit gate in getFilterData / getAuditFilterData).
|
|
182
|
+
isChild: mappedId.img_name !== data.img_name,
|
|
183
|
+
} );
|
|
183
184
|
}
|
|
184
185
|
}
|
|
185
|
-
return
|
|
186
|
+
return customerMap;
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
// Single pass over the master-json rows. Each row's ORIGINAL temp_ids is read
|
|
190
|
+
// exactly once and reassigned to its customer's parent id, so every row sharing
|
|
191
|
+
// a temp_ids is retagged and the retag never feeds back into later lookups.
|
|
192
|
+
const mapFunction = ( personData, customerMap ) => {
|
|
193
|
+
for ( const item of personData ) {
|
|
194
|
+
const mapped = customerMap.get( item.temp_ids );
|
|
195
|
+
if ( !mapped ) continue;
|
|
196
|
+
item.temp_ids = mapped.parentId;
|
|
197
|
+
item.query_status = mapped.isChild ? '' : item.query_status;
|
|
198
|
+
item.demographic = mapped.demographic;
|
|
199
|
+
}
|
|
200
|
+
return personData;
|
|
186
201
|
};
|
|
187
202
|
|
|
188
203
|
export async function isAuditInputFolderExist( req, res, next ) {
|
|
@@ -344,7 +359,8 @@ export async function getAuditFilterData( data ) {
|
|
|
344
359
|
( item ) =>
|
|
345
360
|
item.temp_ids < 20000 &&
|
|
346
361
|
item.temp_ids > 0 &&
|
|
347
|
-
item.person_status === ''
|
|
362
|
+
item.person_status === '' &&
|
|
363
|
+
item.query_status !== '',
|
|
348
364
|
);
|
|
349
365
|
const finalResult = await filterData.map( ( i ) => {
|
|
350
366
|
return { ...i, img: i.index.concat( '_', i.temp_ids ) };
|