forked from BasedHardware/omi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinspect-kg.py
More file actions
52 lines (44 loc) · 1.83 KB
/
Copy pathinspect-kg.py
File metadata and controls
52 lines (44 loc) · 1.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
import sqlite3, os, sys
DB = os.path.join(os.environ["APPDATA"], "omi-windows", "omi.db")
d = sqlite3.connect(DB)
c = d.cursor()
def has_table(name):
return bool(
c.execute(
"select count(*) from sqlite_master where type='table' and name=?", (name,)
).fetchone()[0]
)
tables = sorted(r[0] for r in c.execute("select name from sqlite_master where type='table'"))
print("DB:", DB)
print("TABLES:", tables)
if has_table("indexed_files"):
n = c.execute("select count(*) from indexed_files").fetchone()[0]
print("indexed_files:", n)
rows = c.execute(
"select extension, count(*) c from indexed_files where file_type!='application' and extension!='' group by extension order by c desc limit 15"
).fetchall()
print("top extensions:", rows)
else:
print("indexed_files: NO TABLE")
for t in ("local_kg_nodes", "local_kg_edges"):
if has_table(t):
print(f"{t}:", c.execute(f"select count(*) from {t}").fetchone()[0])
else:
print(f"{t}: NO TABLE (expected until the new build runs once)")
# Verification queries (only meaningful after synthesis runs)
if has_table("local_kg_nodes"):
print("\n--- technology nodes ---")
for r in c.execute(
"select label, summary from local_kg_nodes where node_type='technology' order by label"
):
print(" ", r[0], "|", r[1])
print("\n--- REGRESSION: phantom Flutter/Android/Dart nodes ---")
bad = c.execute(
"select label from local_kg_nodes where label in ('Dart','Android') or label like '%Flutter%'"
).fetchall()
print(" rows (want 0):", bad)
print("\n--- sample project/interest nodes ---")
for r in c.execute(
"select node_type, label, summary from local_kg_nodes where node_type in ('project','interest','org','person') limit 20"
):
print(" ", r[0], "|", r[1], "|", r[2])