first commit
This commit is contained in:
21
scripts/inspect_viewperday.js
Normal file
21
scripts/inspect_viewperday.js
Normal file
@@ -0,0 +1,21 @@
|
||||
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();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user