Skip to content

Commit

Permalink
Merge branch 'console' into console-v0.3
Browse files Browse the repository at this point in the history
  • Loading branch information
jagankumar-egov committed Dec 6, 2024
2 parents f21ef2d + 963fa7d commit 61a6c7c
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 15 deletions.
40 changes: 32 additions & 8 deletions health-services/project-factory/src/server/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,26 +149,50 @@ const httpRequest = async (
errorResponse?.data || { Errors: [{ code: error.message, description: error.stack }] }
)}`
);
if (retry|| config.values.autoRetryIfHttpError?.includes(errorResponse?.data?.Errors?.[0]?.code)) {
logger.info(`retrying the failed api call since retry is enabled or error is equal to configured ${config.values.autoRetryIfHttpError}`);
if (
retry ||
(config.values.autoRetryIfHttpError &&
config.values.autoRetryIfHttpError?.includes(
errorResponse?.data?.Errors?.[0]?.code
))
) {
logger.info(
`retrying the failed api call since retry is enabled or error is equal to configured ${config.values.autoRetryIfHttpError}`
);
attempt++;
if (attempt >= maxAttempts) {
if (dontThrowError) {
logger.warn(`Maximum retry attempts reached for httprequest with url ${_url}`);
return errorResponse?.data || { Errors: [{ code: error.message, description: error.stack }] };
logger.warn(
`Maximum retry attempts reached for httprequest with url ${_url}`
);
return (
errorResponse?.data || {
Errors: [{ code: error.message, description: error.stack }],
}
);
} else {
throwTheHttpError(errorResponse, error, _url);
}
}
logger.warn(`Waiting for 20 seconds before retrying httprequest with url ${_url}`);
logger.warn(
`Waiting for 20 seconds before retrying httprequest with url ${_url}`
);
await new Promise((resolve) => setTimeout(resolve, 20000));
} else if (dontThrowError) {
logger.warn(
`Error occurred while making request to ${getServiceName(_url)}: returning error response ${JSON.stringify(
errorResponse?.data || { Errors: [{ code: error.message, description: error.stack }] }
`Error occurred while making request to ${getServiceName(
_url
)}: returning error response ${JSON.stringify(
errorResponse?.data || {
Errors: [{ code: error.message, description: error.stack }],
}
)}`
);
return errorResponse?.data || { Errors: [{ code: error.message, description: error.stack }] };
return (
errorResponse?.data || {
Errors: [{ code: error.message, description: error.stack }],
}
);
} else {
throwTheHttpError(errorResponse, error, _url);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1482,13 +1482,19 @@ function validateBoundarySheetDataInCreateFlow(boundarySheetData: any, localized
export function validateEmptyActive(data: any, type: string, localizationMap?: { [key: string]: string }) {
let isActiveRowsZero = true;
const activeColumnName = createAndSearch?.[type]?.activeColumnName ? getLocalizedName(createAndSearch?.[type]?.activeColumnName, localizationMap) : null;
data.forEach((item: any) => {
const active = activeColumnName ? item[activeColumnName] : "Active";
if (active == "Active") {
isActiveRowsZero = false;
return;
}
});
if(Array.isArray(data)){
data.forEach((item: any) => {
const active = activeColumnName ? item[activeColumnName] : "Active";
if (active == "Active") {
isActiveRowsZero = false;
return;
}
});
}
else{
// Data is not coming from a single sheet so no require for this active check
isActiveRowsZero = false;
}
if(isActiveRowsZero){
throwError("COMMON", 400, "VALIDATION_ERROR", "At least one active row is required");
}
Expand Down

0 comments on commit 61a6c7c

Please sign in to comment.