Reduce hot run polling pressure
This commit is contained in:
@@ -10,6 +10,9 @@ import { cx } from "../utils/classes";
|
||||
|
||||
type ModuleState<T> = { status: "loading" } | { status: "error"; reason: string } | { status: "ready"; data: T };
|
||||
|
||||
const maintenanceJobStates: JobResponse["state"][] = ["failed"];
|
||||
const maintenanceJobLimit = 100;
|
||||
|
||||
export function MaintenancePage({ session, operations, onNavigate }: PageComponentProps) {
|
||||
const [jobs, setJobs] = useState<ModuleState<JobResponse[]>>({ status: "loading" });
|
||||
const [servers, setServers] = useState<ModuleState<ServerInstanceResponse[]>>({ status: "loading" });
|
||||
@@ -18,7 +21,7 @@ export function MaintenancePage({ session, operations, onNavigate }: PageCompone
|
||||
const refreshJobs = useCallback(async () => {
|
||||
setJobs({ status: "loading" });
|
||||
try {
|
||||
const response = await platformApiClient.listJobs();
|
||||
const response = await platformApiClient.listJobs(undefined, { states: maintenanceJobStates, limit: maintenanceJobLimit });
|
||||
setJobs({ status: "ready", data: response.items });
|
||||
} catch (error) {
|
||||
setJobs({ status: "error", reason: error instanceof Error ? error.message : "加载失败" });
|
||||
|
||||
Reference in New Issue
Block a user