diff --git a/src/views/pages/ksGitRepo/ksCodeParser/KsGitCodeParser.vue b/src/views/pages/ksGitRepo/ksCodeParser/KsGitCodeParser.vue
index 0955dc6..cb63466 100644
--- a/src/views/pages/ksGitRepo/ksCodeParser/KsGitCodeParser.vue
+++ b/src/views/pages/ksGitRepo/ksCodeParser/KsGitCodeParser.vue
@@ -73,22 +73,9 @@
-
-
-
-
-
@@ -257,7 +244,7 @@ const logoSrc = ref(logo);
onMounted(() => {
fetchCodeRepoInfo();
-
+ startPolling();
});
const refreshPage = () => {
@@ -279,18 +266,19 @@ const handleCloneRepoWebSocketMessage = (data) => {
};
//websocket end
-//polling
-const updateParsingProgress2 = async (data) => {
+//updateParsingProgress
+const updateParsingProgress = async (data) => {
const updatedData = await Promise.all((data || []).map(async (d) => {
- if (d.parseStatus == "IN PROGRESS") {
+ if (d.parseStatus === "IN PROGRESS") {
try {
- const parseResponse = await axios.get(`/get-parse-status?id=${d.parseId}`)
- console.log("parseResponse: ", parseResponse.data);
+ const parseResponse = await axios.get(`/get-parse-status?id=${d.parseId}`);
d.parseInfo = parseResponse.data;
} catch (error) {
console.error("Error fetching parse status:", error);
d.parseInfo = { totalFiles: 0, parsedFiles: 0 };
- };
+ }
+ } else if (d.parseStatus === "DONE") {
+ d.parseInfo = { totalFiles: 1, parsedFiles: 1 };
} else {
d.parseInfo = { totalFiles: 0, parsedFiles: 0 };
}
@@ -298,20 +286,35 @@ const updateParsingProgress2 = async (data) => {
}));
return updatedData;
};
-const updateParsingProgress = async () => {
+
+//polling
+// Function to start polling
+let pollingInterval = null;
+function startPolling() {
+ // Set polling interval (every 5 seconds in this case)
+ pollingInterval = setInterval(pollBackendAPI, 10000);
+ console.log("Polling started.");
+}
+
+// Function to stop polling
+function stopPolling() {
+ clearInterval(pollingInterval);
+ console.log("All parseStatus are DONE, polling stopped.");
+}
+const pollBackendAPI = () => {
for (let i = 0; i < codeRepoInfo.value.length; i++) {
- if (codeRepoInfo.value[i].parseStatus == "IN PROGRESS" && codeRepoInfo.value[i].id != '6710d7eda8050cb3b2d088a0') {
- axios.get(`/get-parse-status?id=${codeRepoInfo.value[i].parseId}`)
- .then(parseResponse => {
- console.log("parseResponse: ", parseResponse.data)
- codeRepoInfo.value[i].parseInfo = parseResponse.data;
- })
- .catch(error => {
- console.error("Error fetching parse status:", error);
- });
- } else {
- codeRepoInfo.value[i].parseInfo = { totalFiles: 101, parsedFiles: 101 };
+ // Check if all parseStatus are DONE or ERROR
+ const allDoneOrError = codeRepoInfo.value.every(repo => repo.parseStatus === 'DONE');
+ if (allDoneOrError) {
+ stopPolling();
+ return; //exit from loop
}
+ else if (codeRepoInfo.value[i].parseStatus === 'IN PROGRESS' || codeRepoInfo.value[i].parseStatus === 'ERROR') {
+ fetchCodeRepoInfo();
+ console.log("Condition met");
+ return; //exit from loop
+ }
+
}
};
@@ -340,17 +343,10 @@ function calculateCustomerTotal(name) {
const fetchCodeRepoInfo = async () => {
try {
const response = await axios.get('/fe-api/ks_git_repos');
- //codeRepoInfo.value = response.data;
- console.log(response.data);
+ //console.log(response.data);
const filterDate = getCustomDatewithAllResponse(response.data);
const filterParseEnabled = getCustomJsonWithJavaParseEnabled(filterDate);
- const addParseInfo = await updateParsingProgress2(filterParseEnabled);
- //console.log("updateParsingProgress2 : ", updateParsingProgress2(codeRepoInfo.value));
- console.log("**************")
- console.log("addParseInfo : ", addParseInfo);
- codeRepoInfo.value = addParseInfo;
- console.log("codeRepoInfo.value : ", codeRepoInfo.value);
- //updateParsingProgress();
+ codeRepoInfo.value = await updateParsingProgress(filterParseEnabled);
loading.value = false;
} catch (error) {
console.error('Failed to fetch code repo info:', error);
@@ -369,7 +365,7 @@ const getCustomJsonWithJavaParseEnabled = (data) => {
};
-//ingest git repo functions
+//parse git repo functions
const parseGitRepo = (data) => {
console.log(data)
const requestBody = {