Skip to content

Commit

Permalink
Apply suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
  • Loading branch information
jagankumar-egov and coderabbitai[bot] authored Dec 5, 2024
1 parent 85a20ca commit ad5a88f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ async function retryProjectTypeCampaignService(request: express.Request) {
async function fetchFromMicroplanService(request: express.Request) {
logger.info("FETCHING DATA FROM MICROPLAN");
await validateMicroplanRequest(request);
logger.info("Update Campaign Object")
logger.info("UPDATE CAMPAIGN OBJECT")
await updateCampaignAfterSearch(request, "MICROPLAN_FETCHING")
logger.info("Validated request successfully");
processFetchMicroPlan(request);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,16 @@ const downloadDataService = async (request: express.Request) => {

const type = request.query.type;
// Get response data from the database
var responseData = await searchGeneratedResources(request);
const responseData = await searchGeneratedResources(request);
const resourceDetails = await getResourceDetails(request);

// Check if response data is available
if (!responseData || responseData.length === 0 && !request?.query?.id || responseData?.[0]?.status === generatedResourceStatuses.failed) {
logger.error("No data of type " + type + " with status Completed or with given id present in db ")
if (
!responseData ||
(responseData.length === 0 && !request?.query?.id) ||
responseData?.[0]?.status === generatedResourceStatuses.failed
) {
logger.error(`No data of type ${type} with status Completed or with given id present in db`)
// Throw error if data is not found
const newRequestBody = {
RequestInfo: request?.body?.RequestInfo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function validateInConsistency(request: any, userMapping: any, emailKey: any, na
request.body.ResourceDetails.status = resourceDataStatuses.invalid
}

request.body.sheetErrorDetails = request?.body?.sheetErrorDetails ? [...request?.body?.sheetErrorDetails, ...overallInconsistencies] : overallInconsistencies;
request.body.sheetErrorDetails = Array.isArray(request.body.sheetErrorDetails) ? [...request.body.sheetErrorDetails, ...overallInconsistencies] : overallInconsistencies;
}

function validateNationalDuplicacy(request: any, userMapping: any, phoneNumberKey: any) {
Expand Down Expand Up @@ -150,7 +150,7 @@ function convertDataSheetWise(userMapping: any) {
function getInconsistencyErrorMessage(phoneNumber: any, userRecords: any) {
// Create the error message mentioning all the records for this phone number
const errors: any = []
const errorMessage = `User details for the same contact number isn't matching. Please check the user's name or email ID`;
const errorMessage = `User details for the same contact number don't match. Please check the user's name or email ID`;
for (const record of userRecords) {
errors.push({ rowNumber: record.row, sheetName: record.sheet, status: "INVALID", errorDetails: errorMessage });
}
Expand Down Expand Up @@ -337,7 +337,9 @@ export async function createPlanFacilityForMicroplan(request: any, localizationM

function getPlanFacilityObject(request: any, element: any, planConfigurationName: any, planConfigurationId: any, localizationMap?: any) {
const residingBoundariesColumn = getLocalizedName(`HCM_ADMIN_CONSOLE_RESIDING_BOUNDARY_CODE_MICROPLAN`, localizationMap);
const singularResidingBoundary = element?.[residingBoundariesColumn]?.split(",")?.[0];
const singularResidingBoundary = element?.[residingBoundariesColumn]
? element[residingBoundariesColumn].split(",")[0]
: null;
const facilityStatus = element?.facilityDetails?.isPermanent ? "Permanent" : "Temporary";
const facilityType = element?.facilityDetails?.usage;
const hierarchyType = request?.body?.ResourceDetails?.hierarchyType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async function fetchFileUrls(request: any, processedFileStoreIdForUSerOrFacility
"get"
);
} catch (error) {
console.error("Error fetching file URLs:", error);
logger.error("Error fetching file URLs:", error);
throw error;
}
}
Expand Down Expand Up @@ -240,7 +240,7 @@ function updateTargetValues(originalData: any, newData: any, localizedHeaders: a
for (let i = boundaryCodeIndex + 1; i < localizedHeaders.length; i++) {
updatedValues.push(newRow[i]); // Store original value
if (rowIndex === 0) { // Only modify the first row
const modifiedValue = newRow[i] + "(OLD)"; // Create modified value with (OLD) suffix
const modifiedValue = `${newRow[i]}(OLD)`; // Create modified value with (OLD) suffix
newRow[i] = modifiedValue; // Update newRow[i] with the modified value
oldTargetColumnsToHide.push(modifiedValue); // Push the modified value
}
Expand Down

0 comments on commit ad5a88f

Please sign in to comment.