Update hivegrid-cloud reference to latest main

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
davidandClaude Fable 5 committed 2026-07-08 16:15:37 +02:00
1 parent e98d38e716
commit 7b21524c86
3781 files changed
+373484 -225607

No files matched your search

@@ -1,104 +1,18 @@
import { TFunction } from "i18next";
import { DefaultEntityTypes } from "~/application/dtos/shared/DefaultEntityTypes";
import { Stat } from "~/application/dtos/stats/Stat";
import { getStatChangePercentage, getStatChangeType } from "../app/DashboardUtils";
import { db } from "../db.server";
import { EntitySimple, getAllEntities } from "../db/entities/entities.db.server";
import { TenantSimple } from "../db/tenants.db.server";
import { RowsApi } from "../api/.server/RowsApi";
export async function getAppDashboardStats({
tenant,
gte,
entities,
}: {
t: TFunction;
tenant: TenantSimple | null;
gte: Date | undefined | undefined;
entities?: EntitySimple[];
gte: Date | undefined;
}): Promise<Stat[]> {
// Entity/row-based dashboard stats were produced by the generic entity-builder,
// which has been removed. There are no entity stats to compute anymore.
if (!tenant) {
return [];
}
if (!entities) {
entities = await getAllEntities({ tenantId: tenant.id, active: true, types: [DefaultEntityTypes.All, DefaultEntityTypes.AppOnly] });
}
const promises = entities.map((entity) => getEntityStat(entity, tenant.id, gte));
const stats = await Promise.all(promises);
return stats;
}
export async function getEntityStat(entity: EntitySimple, tenantId: string, gte: Date | undefined) {
const { total, added } = await getRowsCreatedSince(entity.id, tenantId, gte);
const stat: Stat = {
name: entity.titlePlural,
hint: "",
stat: added.toString(),
previousStat: (total - added).toString(),
change: getStatChangePercentage(added, total) + "%",
changeType: getStatChangeType(added, total),
entity: {
slug: entity.slug,
},
};
return stat;
}
async function getRowsCreatedSince(entityId: string, tenantId: string, gte: Date | undefined) {
const [added, total] = await Promise.all([
db.row.count({
where: {
entityId,
tenantId,
createdAt: {
gte,
},
},
}),
db.row.count({
where: {
entityId,
tenantId,
},
}),
]);
return {
added,
total,
};
}
export type EntitySummaryDto = {
order: number;
rowsData: RowsApi.GetRowsData;
};
export async function getEntitySummaries({
entities,
tenantId,
}: {
entities: { name: string; pageSize?: number }[];
tenantId: string | null;
}): Promise<EntitySummaryDto[]> {
const entitySummaries: EntitySummaryDto[] = [];
await Promise.all(
entities.map(async ({ name, pageSize }, idx) => {
const entitySummary = {
order: idx,
rowsData: await RowsApi.getAll({
entity: { name },
tenantId,
pageSize: pageSize || 3,
urlSearchParams: new URLSearchParams({
view: "null",
}),
}),
};
entitySummaries.push(entitySummary);
})
);
return entitySummaries;
return [];
}