62 lines
2.5 KiB
TypeScript
62 lines
2.5 KiB
TypeScript
/**
|
|
* Summarize current database: who (user tier) can use what (tools by accessLevel).
|
|
* Run: npx ts-node scripts/summarize-db-access.ts
|
|
*/
|
|
|
|
import { PrismaClient } from '@prisma/client';
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const tools = await prisma.tool.findMany({
|
|
select: { slug: true, category: true, accessLevel: true, countsAsOperation: true },
|
|
orderBy: [{ category: 'asc' }, { slug: 'asc' }],
|
|
});
|
|
|
|
const byAccess: Record<string, string[]> = { GUEST: [], FREE: [], PREMIUM: [] };
|
|
for (const t of tools) {
|
|
byAccess[t.accessLevel].push(t.slug);
|
|
}
|
|
|
|
console.log('\n📊 Database Access Summary\n');
|
|
console.log('=== WHO CAN USE WHAT ===');
|
|
console.log('');
|
|
console.log('| User Tier | Can Use Tools | Count |');
|
|
console.log('|-----------|---------------|-------|');
|
|
console.log(`| GUEST | accessLevel=GUEST only | ${byAccess.GUEST.length} |`);
|
|
console.log(`| FREE | GUEST + FREE | ${byAccess.GUEST.length + byAccess.FREE.length} |`);
|
|
console.log(`| DAY_PASS | All | ${tools.length} |`);
|
|
console.log(`| PRO | All | ${tools.length} |`);
|
|
console.log('');
|
|
console.log('=== BY ACCESS LEVEL ===');
|
|
console.log(` GUEST: ${byAccess.GUEST.length} tools (anyone, no account)`);
|
|
console.log(` FREE: ${byAccess.FREE.length} tools (registered free users)`);
|
|
console.log(` PREMIUM: ${byAccess.PREMIUM.length} tools (Day Pass or Pro only)`);
|
|
console.log(` TOTAL: ${tools.length} tools`);
|
|
console.log('');
|
|
console.log('=== BY CATEGORY ===');
|
|
const byCat: Record<string, { GUEST: number; FREE: number; PREMIUM: number }> = {};
|
|
for (const t of tools) {
|
|
if (!byCat[t.category]) byCat[t.category] = { GUEST: 0, FREE: 0, PREMIUM: 0 };
|
|
byCat[t.category][t.accessLevel]++;
|
|
}
|
|
for (const cat of Object.keys(byCat).sort()) {
|
|
const c = byCat[cat];
|
|
console.log(` ${cat.padEnd(10)} | GUEST: ${String(c.GUEST).padStart(2)} | FREE: ${String(c.FREE).padStart(2)} | PREMIUM: ${String(c.PREMIUM).padStart(2)} |`);
|
|
}
|
|
console.log('');
|
|
console.log('=== COUNTS AS OPERATION (ops limit) ===');
|
|
const countsYes = tools.filter((t) => t.countsAsOperation).length;
|
|
const countsNo = tools.filter((t) => !t.countsAsOperation).length;
|
|
console.log(` countsAsOperation=true: ${countsYes} tools (consume daily/24h ops limit)`);
|
|
console.log(` countsAsOperation=false: ${countsNo} tools (unlimited, no ops check)`);
|
|
console.log('');
|
|
|
|
await prisma.$disconnect();
|
|
}
|
|
|
|
main().catch((e) => {
|
|
console.error(e);
|
|
process.exit(1);
|
|
});
|