-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_firestore.ts
More file actions
68 lines (61 loc) · 2.35 KB
/
Copy pathdebug_firestore.ts
File metadata and controls
68 lines (61 loc) · 2.35 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
import { initializeApp, cert, getApps } from "firebase-admin/app";
import { getFirestore } from "firebase-admin/firestore";
import fs from "fs";
import path from "path";
// Load .env.local manually
const envPath = path.resolve(process.cwd(), ".env.local");
if (fs.existsSync(envPath)) {
const envContent = fs.readFileSync(envPath, "utf-8");
envContent.split("\n").forEach(line => {
const match = line.match(/^([^=]+)=(.*)$/);
if (match) {
const key = match[1].trim();
let value = match[2].trim();
if ((value.startsWith('"') && value.endsWith('"')) || (value.startsWith("'") && value.endsWith("'"))) {
value = value.slice(1, -1);
}
process.env[key] = value;
}
});
}
// Initialize Firebase Admin
if (getApps().length === 0) {
if (process.env.FIREBASE_SERVICE_ACCOUNT_KEY) {
initializeApp({
credential: cert(JSON.parse(process.env.FIREBASE_SERVICE_ACCOUNT_KEY)),
});
} else {
initializeApp({
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID
});
}
}
async function inspectLatestProject() {
const db = getFirestore();
const projects = await db.collection("projects")
.orderBy("createdAt", "desc")
.limit(1)
.get();
if (projects.empty) {
console.log("No projects found.");
return;
}
const project = projects.docs[0].data();
console.log("Latest Project ID:", projects.docs[0].id);
console.log("Status:", project.status);
console.log("Progress:", project.processingProgress);
console.log("Questions Count:", project.questions?.length);
if (project.questions) {
project.questions.forEach((q: any, i: number) => {
console.log(`\nQuestion ${i + 1}:`);
console.log(" ID:", q.id);
console.log(" Question:", q.question);
console.log(" Time:", q.timestamp);
console.log(" URL - Transition:", q.transitionVideoUrl || q.transitionToQuestionVideoUrl || "(missing)");
console.log(" URL - LipSync:", q.lipSyncQuestionVideoUrl || "(missing)");
console.log(" URL - Waiting:", q.waitingVideoUrl || "(missing)");
console.log(" URL - Audio:", q.questionAudioUrl || "(missing)");
});
}
}
inspectLatestProject().catch(console.error);