Skip to content

Commit

Permalink
✨ Optimize polling to only occur when a task is active (#1715) (#1736)
Browse files Browse the repository at this point in the history
Addresses part of https://issues.redhat.com/browse/MTA-2359

Signed-off-by: Ian Bolton <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>

Signed-off-by: Ian Bolton <[email protected]>
Signed-off-by: Cherry Picker <[email protected]>
Co-authored-by: Ian Bolton <[email protected]>
  • Loading branch information
github-actions[bot] and ibolton336 authored Mar 4, 2024
1 parent 1611d82 commit 02ca259
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,10 @@ export const ApplicationsTable: React.FC = () => {
const getTask = (application: Application) =>
tasks.find((task: Task) => task.application?.id === application.id);

const { tasks } = useFetchTasks({ addon: "analyzer" }, isAnalyzeModalOpen);
const { tasks, hasActiveTasks } = useFetchTasks(
{ addon: "analyzer" },
isAnalyzeModalOpen
);

const isTaskCancellable = (application: Application) => {
const task = getTask(application);
Expand Down Expand Up @@ -213,7 +216,7 @@ export const ApplicationsTable: React.FC = () => {
isFetching: isFetchingApplications,
error: applicationsFetchError,
refetch: fetchApplications,
} = useFetchApplications();
} = useFetchApplications(!hasActiveTasks);

const { assessments, isFetching: isFetchingAssesments } =
useFetchAssessments();
Expand Down
2 changes: 2 additions & 0 deletions client/src/app/queries/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,14 @@ export const useFetchTasks = (
},
onError: (err) => console.log(err),
});
const hasActiveTasks = data && data.length > 0;

return {
tasks: data || [],
isFetching: isLoading,
fetchError: error,
refetch,
hasActiveTasks,
};
};

Expand Down

0 comments on commit 02ca259

Please sign in to comment.