Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fixed min time, draft logic #879

Merged
merged 1 commit into from
Jun 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const UploadData = ({ formData, onSelect, ...props }) => {
const { data: Schemas, isLoading: isThisLoading } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "adminSchema" }]);

const { data: readMe } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "ReadMeConfig" }]);
const { data: baseTimeOut } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "baseTimeOut" }]);
const { data: baseTimeOut } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "baseTimeout" }]);
const [sheetHeaders, setSheetHeaders] = useState({});
const [translatedSchema, setTranslatedSchema] = useState({});
const [readMeInfo, setReadMeInfo] = useState({});
Expand Down Expand Up @@ -306,16 +306,6 @@ const UploadData = ({ formData, onSelect, ...props }) => {
.map(({ index, errors }) => {
const formattedErrors = errors
.map((error) => {
// let formattedError = `${error.instancePath}: ${error.message}`;
// if (error.keyword === "enum" && error.params && error.params.allowedValues) {
// formattedError += `. Allowed values are: ${error.params.allowedValues.join("/ ")}`;
// }
// return formattedError;
// })
// .join(", ");
// return `Data at row ${index}: ${formattedErrors}`;
// })
// .join(" , ");
let instancePath = error.instancePath || ""; // Assign an empty string if dataPath is not available
if (instancePath.startsWith("/")) {
instancePath = instancePath.slice(1);
Expand Down Expand Up @@ -395,6 +385,7 @@ const UploadData = ({ formData, onSelect, ...props }) => {
let validate = ajv.compile(translatedSchema[type]);
const errors = []; // Array to hold validation errors


data.forEach((item, index) => {
if (!validate(item)) {
errors.push({ index: (item?.["!row#number!"] || item?.["__rowNum__"]) + 1, errors: validate.errors });
Expand Down Expand Up @@ -423,22 +414,11 @@ const UploadData = ({ formData, onSelect, ...props }) => {
// return true;
// }

console.log("error" , errors);
if (errors.length > 0) {
const errorMessage = errors
.map(({ index, errors }) => {
const formattedErrors = errors
.map((error) => {
// let formattedError = `${error.instancePath}: ${error.message}`;
// if (error.keyword === "enum" && error.params && error.params.allowedValues) {
// formattedError += `. Allowed values are: ${error.params.allowedValues.join("/ ")}`;
// }
// return formattedError;
// })
// .join(", ");
// return `Data at row ${index}: ${formattedErrors}`;
// })
// .join(" , ");
let instancePath = error.instancePath || ""; // Assign an empty string if dataPath is not available
if (instancePath.startsWith("/")) {
instancePath = instancePath.slice(1);
Expand All @@ -461,6 +441,7 @@ const UploadData = ({ formData, onSelect, ...props }) => {
})
.join(", ");


setIsError(true);
targetError.push(errorMessage);
return false;
Expand Down Expand Up @@ -796,7 +777,7 @@ const UploadData = ({ formData, onSelect, ...props }) => {
type,
tenantId,
id,
baseTimeOut?.["HCM-ADMIN-CONSOLE"]?.baseTimeOut?.[0]?.baseTimeOut
baseTimeOut?.["HCM-ADMIN-CONSOLE"]
);
if (temp?.isError) {
setLoader(false);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export const baseTimeOut =
{
baseTimeOut: 100
baseTimeOut: 100,
maxTime: 5000
Comment on lines +3 to +4
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The references to baseTimeOut in useResourceData.js and UploadData.js do not appear to be updated to reflect the new structure with maxTime.

  • useResourceData.js:

    • Line 80: const baseDelay = baseTimeOut?.baseTimeout?.[0]?.baseTimeOut;
    • Line 81: const maxTime = baseTimeOut?.baseTimeout?.[0]?.maxTime;
  • UploadData.js:

    • Line 51: const { data: baseTimeOut } = Digit.Hooks.useCustomMDMS(tenantId, "HCM-ADMIN-CONSOLE", [{ name: "baseTimeout" }]);
    • Line 780: baseTimeOut?.["HCM-ADMIN-CONSOLE"]

These lines should be updated to use the correct structure introduced in the configuration update.

  • Update the references in useResourceData.js and UploadData.js to use the new baseTimeOut structure.
Analysis chain

The configuration update looks correct. Ensure that all references to baseTimeOut in the codebase are updated to work with the new structure.

Scripts executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Description: Verify all references to `baseTimeOut` are correctly updated.

# Test: Search for the object usage. Expect: Only occurances of the new structure.
rg --type javascript $'baseTimeOut'

Length of output: 69



Script:

#!/bin/bash
# Description: Verify all references to `baseTimeOut` are correctly updated.

# Test: Search for the object usage. Expect: Only occurrences of the new structure.
rg --type js $'baseTimeOut'

Length of output: 1272



Script:

#!/bin/bash
# Description: Verify specific lines in `useResourceData.js` and `UploadData.js` for correct usage of the new `baseTimeOut` structure.

# Check the specific lines in `useResourceData.js`
rg --line-number --context 2 'baseTimeOut' micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useResourceData.js

# Check the specific lines in `UploadData.js`
rg --line-number --context 2 'baseTimeOut' micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/components/UploadData.js

Length of output: 1289

};

Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,9 @@ export const useResourceData = async (data, hierarchyType, type, tenantId, id ,

let searchResponse;
let status = "validation-started";
const baseDelay = baseTimeOut;
let retryInterval = baseDelay * jsonDataLength;
const baseDelay = baseTimeOut?.baseTimeout?.[0]?.baseTimeOut;
const maxTime = baseTimeOut?.baseTimeout?.[0]?.maxTime;
let retryInterval = Math.min(baseDelay * jsonDataLength , maxTime);

await new Promise((resolve) => setTimeout(resolve, retryInterval));

Expand All @@ -96,7 +97,6 @@ export const useResourceData = async (data, hierarchyType, type, tenantId, id ,
});
status = searchResponse?.ResourceDetails?.[0]?.status;
if (status !== "failed" && status !== "invalid" && status !== "completed") {
retryInterval *= 2;
await new Promise((resolve) => setTimeout(resolve, retryInterval));
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -374,13 +374,19 @@ const SetupCampaign = ({ hierarchyType }) => {
},
},
HCM_CAMPAIGN_UPLOAD_BOUNDARY_DATA: {
uploadBoundary: { uploadedFile: draftData?.resources?.filter((i) => i?.type === "boundaryWithTarget") },
uploadBoundary: { uploadedFile: draftData?.resources?.filter((i) => i?.type === "boundaryWithTarget"),
isSuccess : draftData?.resources?.filter((i) => i?.type === "boundaryWithTarget").length>0
},
},
HCM_CAMPAIGN_UPLOAD_FACILITY_DATA: {
uploadFacility: { uploadedFile: draftData?.resources?.filter((i) => i?.type === "facility") },
uploadFacility: { uploadedFile: draftData?.resources?.filter((i) => i?.type === "facility") ,
isSuccess : draftData?.resources?.filter((i) => i?.type === "facility").length>0
}
},
HCM_CAMPAIGN_UPLOAD_USER_DATA: {
uploadUser: { uploadedFile: draftData?.resources?.filter((i) => i?.type === "user") },
uploadUser: { uploadedFile: draftData?.resources?.filter((i) => i?.type === "user") ,
isSuccess : draftData?.resources?.filter((i) => i?.type === "user").length>0
},
},
};
setParams({ ...restructureFormData });
Expand Down
Loading