-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeploy@138.197.34.3
More file actions
57 lines (46 loc) · 1.78 KB
/
deploy@138.197.34.3
File metadata and controls
57 lines (46 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import { PrismaClient } from '@prisma/client'
import { PrismaPg } from '@prisma/adapter-pg'
import pg from 'pg'
const pool = new pg.Pool({ connectionString: process.env.DATABASE_URL })
const adapter = new PrismaPg(pool)
const prisma = new PrismaClient({ adapter })
async function analyze() {
const events = await prisma.event.findMany({
select: {
id: true,
title: true,
sourceUrl: true,
sourceEventId: true,
startsAt: true,
},
orderBy: { startsAt: 'asc' }
})
console.log('Total events:', events.length)
const withSourceUrl = events.filter(e => e.sourceUrl)
console.log('Events with sourceUrl:', withSourceUrl.length)
const withSourceEventId = events.filter(e => e.sourceEventId)
console.log('Events with sourceEventId:', withSourceEventId.length)
// Check for duplicate sourceUrls
const urlCounts = new Map<string, number>()
for (const e of withSourceUrl) {
urlCounts.set(e.sourceUrl!, (urlCounts.get(e.sourceUrl!) || 0) + 1)
}
const duplicateUrls = [...urlCounts.entries()].filter(([_, count]) => count > 1)
console.log('\nDuplicate sourceUrls:', duplicateUrls.length)
if (duplicateUrls.length > 0) {
console.log('\nExamples of duplicate URLs:')
for (const [url, count] of duplicateUrls.slice(0, 10)) {
console.log(' ' + count + 'x: ' + url)
const dupes = events.filter(e => e.sourceUrl === url)
for (const d of dupes.slice(0, 3)) {
console.log(' - ' + d.title + ' (' + d.startsAt.toISOString().split('T')[0] + ')')
}
}
}
const uniqueUrls = urlCounts.size
console.log('\nUniqueness: ' + uniqueUrls + '/' + withSourceUrl.length +
' (' + (uniqueUrls/withSourceUrl.length*100).toFixed(1) + '%)')
await prisma.$disconnect()
await pool.end()
}
analyze().catch(console.error)