Skip to content

Commit

Permalink
updates
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfarrell76 committed Dec 3, 2024
1 parent f2935b2 commit e2c9e35
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 22 deletions.
10 changes: 8 additions & 2 deletions src/preference-management/getPreferencesForIdentifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,19 @@ export async function getPreferencesForIdentifiers(
// continue
}
const msg = err?.response?.body || err?.message || '';
if (!msg.includes('ETIMEDOUT')) {
if (!msg.includes('ETIMEDOUT' || '504 Gateway Time-out')) {
throw new Error(
`Received an error from server: ${
err?.response?.body || err?.message
}`,
);
}
logger.warn(
colors.yellow(
'[RETRYING FAILED REQUEST] ' +
`Failed to fetch ${group.length} user preferences from partition ${partitionKey}: ${msg}`,
),
);
const rawResult = await sombra
.post(`v1/preferences/${partitionKey}/query`, {
json: {
Expand All @@ -113,7 +119,7 @@ export async function getPreferencesForIdentifiers(
}
},
{
concurrency: 10,
concurrency: 100,
},
);

Expand Down
4 changes: 2 additions & 2 deletions src/requests/bulkRestartRequests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export async function bulkRestartRequests({
coreIdentifier: requestResponse.coreIdentifier,
attemptedAt: new Date().toISOString(),
});
state.setValue(restartedRequests, 'restartedRequests');
await state.setValue(restartedRequests, 'restartedRequests');
} catch (err) {
const msg = `${err.message} - ${JSON.stringify(
err.response?.body,
Expand All @@ -219,7 +219,7 @@ export async function bulkRestartRequests({
attemptedAt: new Date().toISOString(),
error: clientError || msg,
});
state.setValue(failingRequests, 'failingRequests');
await state.setValue(failingRequests, 'failingRequests');
}
total += 1;
progressBar.update(total);
Expand Down
8 changes: 5 additions & 3 deletions src/requests/mapColumnsToAttributes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,11 @@ export async function mapColumnsToAttributes(
};
}),
);
Object.entries(attributeNameMap).forEach(([k, v]) => {
state.setValue(v, 'attributeNames', k);
});
await Promise.all(
Object.entries(attributeNameMap).map(([k, v]) =>
state.setValue(v, 'attributeNames', k),
),
);

return {
...state.getValue('attributeNames'),
Expand Down
8 changes: 5 additions & 3 deletions src/requests/mapColumnsToIdentifiers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,11 @@ export async function mapColumnsToIdentifiers(
};
}),
);
Object.entries(identifierNameMap).forEach(([k, v]) => {
state.setValue(v, 'identifierNames', k);
});
await Promise.all(
Object.entries(identifierNameMap).map(([k, v]) =>
state.setValue(v, 'identifierNames', k),
),
);

return {
...state.getValue('identifierNames'),
Expand Down
8 changes: 5 additions & 3 deletions src/requests/mapCsvColumnsToApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,10 @@ export async function mapCsvColumnsToApi(
}),
);

getEntries(columnNameMap).forEach(([k, v]) => {
state.setValue(v, 'columnNames', k);
});
await Promise.all(
getEntries(columnNameMap).map(([k, v]) =>
state.setValue(v, 'columnNames', k),
),
);
return columnNameMap;
}
18 changes: 12 additions & 6 deletions src/requests/mapRequestEnumValues.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ export async function mapRequestEnumValues(
Object.values(RequestAction),
state.getValue('requestTypeToRequestAction'),
);
state.setValue(requestTypeToRequestAction, 'requestTypeToRequestAction');
await state.setValue(
requestTypeToRequestAction,
'requestTypeToRequestAction',
);

// Map data subject type
logger.info(colors.magenta('Determining mapping of columns for subject'));
Expand All @@ -66,7 +69,7 @@ export async function mapRequestEnumValues(
internalSubjects.map(({ type }) => type),
state.getValue('subjectTypeToSubjectName'),
);
state.setValue(subjectTypeToSubjectName, 'subjectTypeToSubjectName');
await state.setValue(subjectTypeToSubjectName, 'subjectTypeToSubjectName');

// Map locale
logger.info(colors.magenta('Determining mapping of columns for locale'));
Expand All @@ -75,7 +78,7 @@ export async function mapRequestEnumValues(
Object.values(LanguageKey),
state.getValue('languageToLocale'),
);
state.setValue(languageToLocale, 'languageToLocale');
await state.setValue(languageToLocale, 'languageToLocale');
logger.info(
colors.magenta('Determining mapping of columns for request status'),
);
Expand All @@ -95,7 +98,7 @@ export async function mapRequestEnumValues(
[...Object.values(CompletedRequestStatus), NONE],
state.getValue('statusToRequestStatus'),
);
state.setValue(statusToRequestStatus, 'statusToRequestStatus');
await state.setValue(statusToRequestStatus, 'statusToRequestStatus');

// Map country
logger.info(colors.magenta('Determining mapping of columns for country'));
Expand All @@ -110,7 +113,7 @@ export async function mapRequestEnumValues(
[...Object.values(IsoCountryCode), NONE],
state.getValue('regionToCountry'),
);
state.setValue(regionToCountry, 'regionToCountry');
await state.setValue(regionToCountry, 'regionToCountry');

// Map country sub division
logger.info(
Expand All @@ -127,5 +130,8 @@ export async function mapRequestEnumValues(
[...Object.values(IsoCountrySubdivisionCode), NONE],
state.getValue('regionToCountrySubDivision'),
);
state.setValue(regionToCountrySubDivision, 'regionToCountrySubDivision');
await state.setValue(
regionToCountrySubDivision,
'regionToCountrySubDivision',
);
}
6 changes: 3 additions & 3 deletions src/requests/uploadPrivacyRequestsFromCsv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ export async function uploadPrivacyRequestsFromCsv({
coreIdentifier: requestResponse.coreIdentifier,
attemptedAt: new Date().toISOString(),
});
requestState.setValue(successfulRequests, 'successfulRequests');
await requestState.setValue(successfulRequests, 'successfulRequests');
} catch (err) {
const msg = `${err.message} - ${JSON.stringify(
err.response?.body,
Expand All @@ -286,7 +286,7 @@ export async function uploadPrivacyRequestsFromCsv({
rowIndex: ind,
attemptedAt: new Date().toISOString(),
});
requestState.setValue(duplicateRequests, 'duplicateRequests');
await requestState.setValue(duplicateRequests, 'duplicateRequests');
} else {
const failingRequests = requestState.getValue('failingRequests');
failingRequests.push({
Expand All @@ -295,7 +295,7 @@ export async function uploadPrivacyRequestsFromCsv({
error: clientError || msg,
attemptedAt: new Date().toISOString(),
});
requestState.setValue(failingRequests, 'failingRequests');
await requestState.setValue(failingRequests, 'failingRequests');
if (debug) {
logger.error(colors.red(clientError || msg));
logger.error(
Expand Down

0 comments on commit e2c9e35

Please sign in to comment.