Fix: use seconds for PBS since (#6583)

This commit is contained in:
shamoon
2026-04-19 07:53:25 -07:00
committed by GitHub
parent 10ade1d32f
commit 8322dd9016
3 changed files with 26 additions and 4 deletions

View File

@@ -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) {

View File

@@ -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(<Component service={{ widget: { type: "proxmoxbackupserver" } }} />, {
settings: { hideErrors: false },
});
expect(useWidgetAPI).toHaveBeenNthCalledWith(2, { type: "proxmoxbackupserver" }, "nodes/localhost/tasks", {
errors: true,
limit: 100,
since: 1_776_433_098,
});
});
});

View File

@@ -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",