Performance: fetch all docker container statuses in one request (#7092)

Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
This commit is contained in:
DaddyBoard
2026-09-05 15:17:52 +00:00
committed by GitHub
co-authored by shamoon
parent df34927198
commit 438788240b
11 changed files with 617 additions and 365 deletions
+5 -2
View File
@@ -4,13 +4,16 @@ import useSWR from "swr";
export default function Status({ service, style }) {
const { t } = useTranslation();
const { data, error } = useSWR(`/api/docker/status/${service.container}/${service.server || ""}`);
const { data: response, error } = useSWR(`/api/docker/statuses?server=${encodeURIComponent(service.server || "")}`);
const statusError = error ?? response?.error;
const { statuses } = response ?? {};
const data = statuses ? (statuses[service.container] ?? { status: "not found" }) : undefined;
let statusLabel = t("docker.unknown");
let backgroundClass = "px-1.5 py-0.5 bg-theme-500/10 dark:bg-theme-900/50";
let colorClass = "text-black/20 dark:text-white/40 ";
if (error) {
if (statusError) {
statusLabel = t("docker.error");
colorClass = "text-rose-500/80";
} else if (data) {