-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcleanup-null-links.mjs
More file actions
40 lines (30 loc) · 1.15 KB
/
cleanup-null-links.mjs
File metadata and controls
40 lines (30 loc) · 1.15 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
import Database from 'better-sqlite3';
const db = new Database('./netmap.db');
// Conta link NULL prima del cleanup
const before = db.prepare(`
SELECT COUNT(*) as count FROM links
WHERE remote_device_id IS NULL
AND remote_chassisid IS NULL
AND remote_sysname IS NULL
AND remote_ip IS NULL
`).get();
console.log('=== CLEANUP LINK NULL ===');
console.log('Link NULL prima del cleanup:', before.count);
// Elimina link NULL
const result = db.prepare(`
DELETE FROM links
WHERE remote_device_id IS NULL
AND remote_chassisid IS NULL
AND remote_sysname IS NULL
AND remote_ip IS NULL
`).run();
console.log('Link eliminati:', result.changes);
// Conta link rimanenti
const after = db.prepare('SELECT COUNT(*) as count FROM links').get();
const resolved = db.prepare('SELECT COUNT(*) as count FROM links WHERE remote_device_id IS NOT NULL').get();
console.log('\n=== DOPO CLEANUP ===');
console.log('Link totali:', after.count);
console.log('Link risolti:', resolved.count);
console.log('% Risolti:', Math.round(resolved.count / after.count * 100) + '%');
db.close();
console.log('\n✓ Cleanup completato! Ora puoi ri-eseguire la discovery.');