Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
@@ -0,0 +1,26 @@
|
||||
// Read-only: per demo tenant, count Kontakt (total / demo / visible) + InboxLead,
|
||||
// to confirm whether seeded CRM contacts exist but are hidden by the isDemoData
|
||||
// default filter. RLS-scoped counts. No writes.
|
||||
import { getDbClient } from "@hivegrid/db/client.server";
|
||||
|
||||
const DEMO_SLUGS = ["demo-starter-crm", "demo-pro-crm", "demo-business-crm"];
|
||||
const db = getDbClient() as any;
|
||||
|
||||
async function rls<T>(tenantId: string, cb: (tx: any) => Promise<T>): Promise<T> {
|
||||
return db.$transaction(async (tx: any) => {
|
||||
await tx.$executeRaw`SELECT set_config('app.tenant_id', ${tenantId}, true)`;
|
||||
return cb(tx);
|
||||
});
|
||||
}
|
||||
|
||||
const tenants = await db.tenant.findMany({ where: { slug: { in: DEMO_SLUGS } }, select: { id: true, slug: true } });
|
||||
for (const t of tenants) {
|
||||
await rls(t.id, async (tx: any) => {
|
||||
const kTotal = await tx.kontakt.count({ where: { tenantId: t.id } });
|
||||
const kDemo = await tx.kontakt.count({ where: { tenantId: t.id, isDemoData: true } });
|
||||
const kVisible = await tx.kontakt.count({ where: { tenantId: t.id, isDemoData: false, archivedAt: null } });
|
||||
const leads = await tx.inboxLead.count({ where: { tenantId: t.id } });
|
||||
console.log(`${t.slug}: kontakt total=${kTotal} demo=${kDemo} visible(default)=${kVisible} | inboxLead=${leads}`);
|
||||
});
|
||||
}
|
||||
process.exit(0);
|
||||
Reference in new issue
Block a user