Skip to content

Commit

Permalink
dont drop jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
salazarm committed Feb 20, 2025
1 parent 47b6f0a commit 904a044
Showing 1 changed file with 13 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -442,10 +442,16 @@ export const useRunsForTimeline = ({
return Object.values(jobsWithCompletedRunsAndOngoingRuns);
}, [jobsWithCompletedRunsAndOngoingRuns]);

const allKeys = useMemo(
() => Object.keys(jobsWithCompletedRunsAndOngoingRuns),
[jobsWithCompletedRunsAndOngoingRuns],
);

const unsortedJobs: TimelineRow[] = useMemo(() => {
if (!workspaceOrError || workspaceOrError.__typename === 'PythonError' || _end < Date.now()) {
return jobsWithCompletedRunsAndOngoingRunsValues;
}
const addedJobKeys = new Set();
const addedAdHocJobs = new Set();
const jobs: TimelineRow[] = [];
for (const locationEntry of workspaceOrError.locationEntries) {
Expand Down Expand Up @@ -509,6 +515,7 @@ export const useRunsForTimeline = ({
const runs = [...jobRuns, ...jobTicks];

let row = jobsWithCompletedRunsAndOngoingRuns[jobKey];
addedJobKeys.add(jobKey);
if (row) {
row = {...row, runs};
} else {
Expand All @@ -531,6 +538,11 @@ export const useRunsForTimeline = ({
}
}
}
allKeys.forEach((key) => {
if (!addedJobKeys.has(key)) {
jobs.push(jobsWithCompletedRunsAndOngoingRuns[key]!);
}
});
return jobs;
// Don't add start/end time as a dependency here since it changes often.
// Instead rely on the underlying runs changing in response to start/end changing
Expand All @@ -540,6 +552,7 @@ export const useRunsForTimeline = ({
jobsWithCompletedRunsAndOngoingRunsValues,
runsByJobKey,
jobsWithCompletedRunsAndOngoingRuns,
allKeys,
]);

const jobsWithRuns = useMemo(() => {
Expand Down

0 comments on commit 904a044

Please sign in to comment.