Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,51 @@
|
||||
import type { LoaderFunctionArgs } from "react-router";
|
||||
import { getTranslations } from "~/locale/i18next.server";
|
||||
import { createMetrics } from "~/modules/metrics/services/.server/MetricTracker";
|
||||
import { adminGetAllTenantsWithUsage, type TenantWithUsage } from "~/utils/db/tenants.db.server";
|
||||
import { getPaginationFromCurrentUrl } from "~/utils/helpers/RowPaginationHelper";
|
||||
import PeriodHelper from "~/utils/helpers/PeriodHelper";
|
||||
import { promiseHash } from "~/utils/promises/promiseHash";
|
||||
import { getAdminDashboardStats } from "~/utils/services/adminDashboardService";
|
||||
import { getSetupSteps } from "~/utils/services/setupService";
|
||||
import type { SetupItem } from "~/application/dtos/setup/SetupItem";
|
||||
import type { Stat } from "~/application/dtos/stats/Stat";
|
||||
import type { PaginationDto } from "~/application/dtos/data/PaginationDto";
|
||||
|
||||
export type AdminDashboardLoaderData = {
|
||||
title: string;
|
||||
stats: Stat[];
|
||||
setupSteps: SetupItem[];
|
||||
tenants: {
|
||||
items: TenantWithUsage[];
|
||||
pagination: PaginationDto;
|
||||
};
|
||||
};
|
||||
|
||||
type AdminDashboardDataArgs = Pick<LoaderFunctionArgs, "request" | "params">;
|
||||
|
||||
export async function loadAdminDashboardRouteData({ request, params }: AdminDashboardDataArgs) {
|
||||
const { time, getServerTimingHeader } = await createMetrics({ request, params }, "admin.dashboard");
|
||||
const urlSearchParams = new URL(request.url).searchParams;
|
||||
const currentPagination = getPaginationFromCurrentUrl(urlSearchParams);
|
||||
|
||||
const { t } = await time(getTranslations(request), "getTranslations");
|
||||
const { stats, setupSteps, tenants } = await time(
|
||||
promiseHash({
|
||||
stats: time(
|
||||
getAdminDashboardStats({ t, gte: PeriodHelper.getGreaterThanOrEqualsFromRequest({ request }) }),
|
||||
"admin.dashboard.details.getAdminDashboardStats"
|
||||
),
|
||||
setupSteps: time(getSetupSteps(), "admin.dashboard.details.getSetupSteps"),
|
||||
tenants: time(adminGetAllTenantsWithUsage(undefined, currentPagination), "admin.dashboard.details.adminGetAllTenantsWithUsage"),
|
||||
}),
|
||||
"admin.dashboard.details"
|
||||
);
|
||||
|
||||
const data: AdminDashboardLoaderData = {
|
||||
title: `${t("app.sidebar.dashboard")} | ${process.env.APP_NAME}`,
|
||||
stats,
|
||||
setupSteps,
|
||||
tenants,
|
||||
};
|
||||
return { data, headers: getServerTimingHeader() };
|
||||
}
|
||||
Reference in new issue
Block a user