22 lines
681 B
JavaScript
22 lines
681 B
JavaScript
const { PrismaClient } = require('../app/generated/prisma');
|
|
|
|
(async () => {
|
|
const prisma = new PrismaClient();
|
|
try {
|
|
const totalRows = await prisma.viewPerDay.count();
|
|
const distinct = await prisma.viewPerDay.findMany({ select: { contented: true }, distinct: ['contented'] });
|
|
const top = await prisma.viewPerDay.groupBy({
|
|
by: ['contented'],
|
|
_count: { contented: true },
|
|
orderBy: { _count: { contented: 'desc' } },
|
|
take: 10,
|
|
});
|
|
console.log(JSON.stringify({ totalRows, distinctIds: distinct.length, top }, null, 2));
|
|
} catch (e) {
|
|
console.error(e);
|
|
process.exit(1);
|
|
} finally {
|
|
await prisma.$disconnect();
|
|
}
|
|
})();
|