-
Notifications
You must be signed in to change notification settings - Fork 19
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
HLM-6225_added time out according to data #855
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
export const baseTimeOut = | ||
{ | ||
baseTimeOut: 100 | ||
}; | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,5 +1,11 @@ | ||||||
export const useResourceData = async (data, hierarchyType, type, tenantId, id) => { | ||||||
import axios from 'axios'; | ||||||
import * as XLSX from 'xlsx'; | ||||||
import { baseTimeOut } from '../configs/baseTimeOut'; | ||||||
export const useResourceData = async (data, hierarchyType, type, tenantId, id , baseTimeOut) => { | ||||||
|
||||||
|
||||||
let Type; | ||||||
let jsonDataLength; | ||||||
let Error = { | ||||||
isError: false, | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The variable name - let Error = {
+ let errorDetails = { Committable suggestion
Suggested change
ToolsBiome
|
||||||
error: {}, | ||||||
|
@@ -13,6 +19,29 @@ export const useResourceData = async (data, hierarchyType, type, tenantId, id) = | |||||
Type = "boundaryWithTarget"; | ||||||
} | ||||||
try { | ||||||
if(data){ | ||||||
axios | ||||||
.get("/filestore/v1/files/id", { | ||||||
responseType: "arraybuffer", | ||||||
headers: { | ||||||
"Content-Type": "application/json", | ||||||
Accept: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", | ||||||
"auth-token": Digit.UserService.getUser()?.["access_token"], | ||||||
}, | ||||||
params: { | ||||||
tenantId: Digit.ULBService.getCurrentTenantId(), | ||||||
fileStoreId: data?.[0]?.filestoreId, | ||||||
}, | ||||||
}) | ||||||
.then(async (res) => { | ||||||
const fileData = res.data; | ||||||
const workbook = XLSX.read(fileData, { type: 'buffer' }); | ||||||
const sheetName = workbook.SheetNames[1]; | ||||||
const worksheet = workbook.Sheets[sheetName]; | ||||||
const jsonData = XLSX.utils.sheet_to_json(worksheet); | ||||||
jsonDataLength = jsonData.length; | ||||||
}); | ||||||
} | ||||||
const responseTemp = await Digit.CustomService.getResponse({ | ||||||
url: "/project-factory/v1/data/_create", | ||||||
body: { | ||||||
|
@@ -27,7 +56,9 @@ export const useResourceData = async (data, hierarchyType, type, tenantId, id) = | |||||
}, | ||||||
}, | ||||||
}); | ||||||
|
||||||
response = responseTemp; | ||||||
|
||||||
} catch (error) { | ||||||
if (error?.response && error?.response?.data) { | ||||||
const errorMessage = error?.response?.data?.Errors?.[0]?.message; | ||||||
|
@@ -46,6 +77,10 @@ export const useResourceData = async (data, hierarchyType, type, tenantId, id) = | |||||
|
||||||
let searchResponse; | ||||||
let status = "validation-started"; | ||||||
const baseDelay = baseTimeOut; | ||||||
let retryInterval = baseDelay * jsonDataLength; | ||||||
|
||||||
await new Promise((resolve) => setTimeout(resolve, retryInterval)); | ||||||
|
||||||
// Retry until a response is received | ||||||
while (status !== "failed" && status !== "invalid" && status !== "completed") { | ||||||
|
@@ -61,7 +96,8 @@ export const useResourceData = async (data, hierarchyType, type, tenantId, id) = | |||||
}); | ||||||
status = searchResponse?.ResourceDetails?.[0]?.status; | ||||||
if (status !== "failed" && status !== "invalid" && status !== "completed") { | ||||||
await new Promise((resolve) => setTimeout(resolve, 5000)); | ||||||
retryInterval *= 2; | ||||||
await new Promise((resolve) => setTimeout(resolve, retryInterval)); | ||||||
} | ||||||
} | ||||||
if (Error.isError) { | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Proper error handling is implemented by checking the
isError
property of the response. However, consider adding more detailed logging or error tracking for better debugging and maintenance.+ console.error("Validation error:", errorMessage);
Also applies to: 722-722
Committable suggestion