-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrandomize-priorities.js
More file actions
48 lines (40 loc) · 1.28 KB
/
randomize-priorities.js
File metadata and controls
48 lines (40 loc) · 1.28 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
import sqlite3 from "sqlite3";
const db = new sqlite3.Database("./tasks.db", (err) => {
if (err) {
console.error("Database connection failed:", err);
process.exit(1);
}
console.log("Database connected");
});
console.log("\n🎲 Randomizing importance and urgency values for testing...\n");
// Get all tasks
db.all("SELECT id, name FROM tasks", (err, tasks) => {
if (err) {
console.error("Error:", err);
process.exit(1);
}
let updated = 0;
const total = tasks.length;
tasks.forEach((task) => {
// Random values between 1-10
const importance = Math.floor(Math.random() * 10) + 1;
const urgency = Math.floor(Math.random() * 10) + 1;
db.run(
"UPDATE tasks SET importance = ?, urgency = ? WHERE id = ?",
[importance, urgency, task.id],
(err) => {
if (err) {
console.error(`Error updating task ${task.id}:`, err);
} else {
console.log(`✅ Updated: ${task.name.substring(0, 40)}... (I:${importance}, U:${urgency})`);
}
updated++;
if (updated === total) {
console.log(`\n✅ Updated ${total} tasks with random priorities!`);
console.log("🔄 Refresh your browser to see tasks in different quadrants.\n");
db.close();
}
}
);
});
});