diff --git a/src/widgets/proxmoxbackupserver/component.jsx b/src/widgets/proxmoxbackupserver/component.jsx index 0af1134be..8e31ad100 100644 --- a/src/widgets/proxmoxbackupserver/component.jsx +++ b/src/widgets/proxmoxbackupserver/component.jsx @@ -8,9 +8,14 @@ export default function Component({ service }) { const { t } = useTranslation(); const { widget } = service; + const taskQueryParams = { + errors: true, + limit: 100, + since: Math.floor(Date.now() / 1000) - 24 * 60 * 60, + }; const { data: datastoreData, error: datastoreError } = useWidgetAPI(widget, "status/datastore-usage"); - const { data: tasksData, error: tasksError } = useWidgetAPI(widget, "nodes/localhost/tasks"); + const { data: tasksData, error: tasksError } = useWidgetAPI(widget, "nodes/localhost/tasks", taskQueryParams); const { data: hostData, error: hostError } = useWidgetAPI(widget, "nodes/localhost/status"); if (datastoreError || tasksError || hostError) { diff --git a/src/widgets/proxmoxbackupserver/component.test.jsx b/src/widgets/proxmoxbackupserver/component.test.jsx index c4a2ddd0a..3129ae996 100644 --- a/src/widgets/proxmoxbackupserver/component.test.jsx +++ b/src/widgets/proxmoxbackupserver/component.test.jsx @@ -74,4 +74,23 @@ describe("widgets/proxmoxbackupserver/component", () => { expect(screen.getByText("25")).toBeInTheDocument(); // memory usage expect(screen.getByText("99+")).toBeInTheDocument(); }); + + it("requests failed tasks with a 24 hour since filter in epoch seconds", () => { + vi.spyOn(Date, "now").mockReturnValue(1_776_519_498_000); + + useWidgetAPI + .mockReturnValueOnce({ data: undefined, error: undefined }) + .mockReturnValueOnce({ data: undefined, error: undefined }) + .mockReturnValueOnce({ data: undefined, error: undefined }); + + renderWithProviders(, { + settings: { hideErrors: false }, + }); + + expect(useWidgetAPI).toHaveBeenNthCalledWith(2, { type: "proxmoxbackupserver" }, "nodes/localhost/tasks", { + errors: true, + limit: 100, + since: 1_776_433_098, + }); + }); }); diff --git a/src/widgets/proxmoxbackupserver/widget.js b/src/widgets/proxmoxbackupserver/widget.js index 65298a17c..719849185 100644 --- a/src/widgets/proxmoxbackupserver/widget.js +++ b/src/widgets/proxmoxbackupserver/widget.js @@ -1,7 +1,5 @@ import credentialedProxyHandler from "utils/proxy/handlers/credentialed"; -const since = Date.now() - 24 * 60 * 60 * 1000; - const widget = { api: "{url}/api2/json/{endpoint}", proxyHandler: credentialedProxyHandler, @@ -11,7 +9,7 @@ const widget = { endpoint: "status/datastore-usage", }, "nodes/localhost/tasks": { - endpoint: `nodes/localhost/tasks?errors=true&limit=100&since=${since}`, + endpoint: "nodes/localhost/tasks", }, "nodes/localhost/status": { endpoint: "nodes/localhost/status",