tpmjs/packages/db/test-query.mjs
Ajax Davis 0d7a8e4696 fix(ci): skip lefthook install when .git directory missing
- Prevents lefthook from failing in CI/Vercel environments
- Only installs git hooks when in actual git repository

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-29 13:51:05 +10:00

38 lines
1 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { PrismaClient } from '@prisma/client';
const prisma = new PrismaClient();
async function main() {
console.log('Testing database connection...');
// Test 1: Count tools
console.time('Count tools');
const count = await prisma.tool.count();
console.timeEnd('Count tools');
console.log(`Total tools: ${count}`);
// Test 2: Fetch first 20 tools (same as API)
console.time('Fetch 20 tools');
const tools = await prisma.tool.findMany({
orderBy: [{ qualityScore: 'desc' }, { npmDownloadsLastMonth: 'desc' }, { createdAt: 'desc' }],
take: 20,
});
console.timeEnd('Fetch 20 tools');
console.log(`Fetched ${tools.length} tools`);
if (tools.length > 0) {
console.log('\nFirst tool:', tools[0].npmPackageName);
console.log('Quality score:', tools[0].qualityScore);
} else {
console.log('\n⚠ No tools found in database!');
}
}
main()
.catch((e) => {
console.error('❌ Database error:', e.message);
process.exit(1);
})
.finally(async () => {
await prisma.$disconnect();
});