mirror of
https://github.com/gethomepage/homepage.git
synced 2026-05-18 19:40:58 +08:00
Fix: use seconds for PBS since (#6583)
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user