Repository navigation
Expand file tree
/
Copy pathtest-api-debug.js
More file actions
75 lines (67 loc) · 2.29 KB
/
Copy pathtest-api-debug.js
File metadata and controls
75 lines (67 loc) · 2.29 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// Debug script to test the admin test-submission API logic directly
/* eslint-disable @typescript-eslint/no-require-imports */
const { PrismaClient } = require("@prisma/client")
const { getSetlist } = require("./src/lib/phishnet")
const prisma = new PrismaClient()
async function testAPI() {
try {
console.log("🔍 Testing admin test-submission logic...")
// Get completed shows from the database (excluding test shows)
const existingShows = await prisma.show.findMany({
where: {
venue: {
not: {
contains: "Test Venue",
},
},
// Look for completed shows (shows that have already happened)
isComplete: true,
},
select: {
id: true,
showDate: true,
venue: true,
city: true,
state: true,
},
orderBy: { showDate: "desc" },
take: 10, // Get just 10 for testing
})
console.log(`Found ${existingShows.length} completed shows:`)
existingShows.forEach((show, i) => {
const dateString = show.showDate.toISOString().split("T")[0]
console.log(
` ${i + 1}. ${dateString} - ${show.venue} (${show.city}, ${show.state})`
)
console.log(` Original date: ${show.showDate}`)
console.log(` UTC ISO: ${show.showDate.toISOString()}`)
console.log(` Extracted date: ${dateString}`)
})
// Test the date conversion for the first few shows
console.log("\n🧪 Testing phish.net date lookup for first 3 shows...")
for (let i = 0; i < Math.min(3, existingShows.length); i++) {
const show = existingShows[i]
const dateString = show.showDate.toISOString().split("T")[0]
console.log(`\nTesting ${dateString} (${show.venue}):`)
try {
const setlist = await getSetlist(dateString)
console.log(
` ✅ Found setlist with ${setlist?.songs?.length || 0} songs`
)
if (setlist?.songs?.length >= 10) {
console.log(` 🎯 This show is suitable for testing!`)
break
} else {
console.log(` ❌ Not enough songs (need 10+)`)
}
} catch (error) {
console.log(` ❌ Error: ${error.message}`)
}
}
} catch (error) {
console.error("Error:", error)
} finally {
await prisma.$disconnect()
}
}
testAPI()