-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdebug_ghost_tasks.js
More file actions
78 lines (62 loc) · 2.83 KB
/
debug_ghost_tasks.js
File metadata and controls
78 lines (62 loc) · 2.83 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
76
77
78
const SUPABASE_URL = "https://vawouugtzwmejxqkeqqj.supabase.co";
const SUPABASE_SERVICE_ROLE_KEY = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6InZhd291dWd0endtZWp4cWtlcXFqIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImlhdCI6MTc1Mjc2OTcxMiwiZXhwIjoyMDY4MzQ1NzEyfQ.QH0k26R2xbf4U5z6BmdYG1h_lkeNQ41zDjqL2zWxzxU";
async function main() {
console.log("Fetching all tasks...");
// Fetch up to 1000 tasks
const url = `${SUPABASE_URL}/rest/v1/tasks?select=id,title,status,stage,progress_percentage,completed_checklist_items,metadata&limit=1000`;
try {
const response = await fetch(url, {
headers: {
"apikey": SUPABASE_SERVICE_ROLE_KEY,
"Authorization": `Bearer ${SUPABASE_SERVICE_ROLE_KEY}`,
"Content-Type": "application/json"
}
});
if (!response.ok) {
console.error(`Error: ${response.status} ${response.statusText}`);
console.error(await response.text());
return;
}
const tasks = await response.json();
console.log(`Analyzed ${tasks.length} tasks.`);
let anomalies = 0;
tasks.forEach(task => {
const checklist = task.metadata?.checklist || [];
const completed = task.completed_checklist_items || [];
const progress = task.progress_percentage || 0;
let issue = false;
let msg = "";
if (progress > 100) {
issue = true;
msg += `[PROGRESS > 100%: ${progress}%] `;
}
if (completed.length && checklist.length && completed.length > checklist.length) {
issue = true;
msg += `[CHECKLIST OVERFLOW: ${completed.length}/${checklist.length}] `;
}
if (task.status !== 'COMPLETED' && progress >= 100) {
issue = true;
msg += `[STUCK AT 100%: Status=${task.status}] `;
}
if (issue) {
anomalies++;
console.log("---------------------------------------------------");
console.log(`ID: ${task.id}`);
console.log(`Title: ${task.title}`);
console.log(`Status: ${task.status}`);
console.log(`Stage: ${task.stage}`);
console.log(`Progress: ${progress}%`);
console.log(`Checklist: ${completed.length}/${checklist.length}`);
console.log(`Issue Detected: ${msg}`);
}
});
if (anomalies === 0) {
console.log("No anomalies found in active tasks.");
} else {
console.log(`Found ${anomalies} anomalies.`);
}
} catch (error) {
console.error("Fetch error:", error);
}
}
main();